Exemplo n.º 1
0
 public function permission($sMethod)
 {
     return FlexiConfig::getLoginHandler()->isSuperUser();
     //    if (strtolower($sMethod) == "synctable") {
     //      return FlexiConfig::getLoginHandler()->hasPermission($sTitle);
     //    }
 }
Exemplo n.º 2
0
 public function run()
 {
     try {
         $this->oRequest = $this->_run();
         $oRequest =& $this->oRequest;
         $this->sServiceModule = $oRequest->module;
         $this->sServiceMethod = $oRequest->method;
         $this->sServiceToken = $oRequest->token;
         FlexiLogger::info(__METHOD__, "Running service: " . $this->sServiceModule . "::" . $this->sServiceMethod);
         FlexiLogger::debug(__METHOD__, "Token: " . $this->sServiceToken);
         //throw new Exception("Token: " . $this->sServiceToken);
         //if ($this->sServiceMethod!="login") throw new Exception("Token: " . $this->sServiceToken);
         FlexiConfig::getLoginHandler()->doLoginByToken($this->sServiceToken);
         //if ($this->sServiceMethod!="login") throw new Exception("Logged in as: " . FlexiConfig::getLoginHandler()->getLoggedInUserId());
         FlexiLogger::debug(__METHOD__, "Logged in as: " . FlexiConfig::getLoginHandler()->getLoggedInUserId());
         $this->mRequestData = array();
         if (isset($oRequest->data)) {
             $this->mRequestData = $oRequest->data;
         }
         $mResult = FlexiController::getInstance()->runService($this->sServiceModule, $this->sServiceMethod, $this->mRequestData);
         unset($mResult["control"]);
         FlexiLogger::debug(__METHOD__, "Done service: " . $this->sServiceModule . "::" . $this->sServiceMethod);
         echo $this->returnResult($mResult);
     } catch (Exception $e) {
         echo $this->returnResult(array("status" => false, "return" => null, "msg" => $e->getMessage()));
     }
 }
Exemplo n.º 3
0
 function renderViews()
 {
     $this->oView->addVar("header", $this->renderView("header"));
     $this->oView->addVar("top", FlexiConfig::getLoginHandler()->getUserLanguage());
     $this->oView->addVar("left", "left-");
     $this->oView->addVar("right", "-right");
     $this->oView->addVar("footer", "-footer-");
 }
Exemplo n.º 4
0
 function renderViews()
 {
     if (FlexiConfig::$sFramework == "modx" || FlexiConfig::$sFramework == "modx2") {
         $this->oView->addVar("header", $this->renderView("header"));
         $this->oView->addVar("top", FlexiConfig::getLoginHandler()->getUserLanguage());
         $this->oView->addVar("left", "left-");
         $this->oView->addVar("right", "-right");
         $this->oView->addVar("footer", "-footer-");
     }
     if (!empty(FlexiConfig::$sFramework)) {
         $this->setLayout("");
     } else {
         $this->oView->setTemplate(FlexiConfig::$sAdminTemplate);
     }
 }
Exemplo n.º 5
0
 public function permission($sTitle)
 {
     return FlexiConfig::getLoginHandler()->hasAccessToPolicy("settings");
     //return FlexiConfig::getLoginHandler()->isSuperUser();
     //return FlexiConfig::getLoginHandler()->hasPermission("admin");
 }
Exemplo n.º 6
0
<?php

/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
//#login.form is the rendered html for login
$aLoginForm = !isset($vars["#login.form"]) ? FlexiConfig::getLoginHandler()->getLoginForm() : $vars["#login.form"];
echo $this->renderMarkup($aLoginForm, "login_form");
Exemplo n.º 7
0
 /**
  * Get login handler for logged in user / guest user
  * @return FlexiLoginBaseHandler
  */
 public function getLoginHandler()
 {
     return FlexiConfig::getLoginHandler();
 }
Exemplo n.º 8
0
 public function methodLogin()
 {
     $sUserId = $this->getPost("txtLogin");
     $sPassword = $this->getPost("txtPassword");
     $sRedirect = $this->getRequest("refurl");
     $iStandalone = $this->getRequest("standalone", 0);
     $sRemember = $this->getRequest("rememberme", false);
     $sContext = $this->getRequest("context", "");
     if (FlexiConfig::$sFramework == "modx") {
         $sLoginMode = $this->getRequest("webloginmode");
         if (!empty($sLoginMode)) {
             //logout of modx core...
             //so we redirect to main
             $this->setViewName("returnhome");
             return false;
         }
     }
     //is logout
     if (FlexiConfig::$sFramework == "modx2") {
         if ($this->getRequest("service") == "logout") {
             $this->setViewName("returnhome");
             return false;
         }
     }
     //FlexiLogger::info(__METHOD__, "Attemptng to login: "******", pwd: " . $sPassword);
     $sRedirect = empty($sRedirect) ? "" : FlexiCryptUtil::b64Decrypt($sRedirect);
     if (FlexiConfig::$sFramework == "modx2") {
         $sRedirect = str_replace(array('?service=logout', '&service=logout', '&amp;service=logout'), '', $sRedirect);
     }
     $aOption = array("url" => $sRedirect);
     $aOption["standalone"] = $iStandalone == 1 ? true : false;
     $aOption["rememberme"] = empty($sRemember) ? false : true;
     $aOption["context"] = empty($sContext) ? null : $sContext;
     //die("url: " . $sRedirect);
     $oLogin = FlexiConfig::getLoginHandler();
     if (!$oLogin->existsUser($sUserId)) {
         $sMessage = flexiT("Login fail", "first");
         $this->addMessage($sMessage, "error");
         $aOption["error"] = $sMessage;
         FlexiLogger::error(__METHOD__, $sMessage);
         $sURL = FlexiConfig::getLoginHandler()->getLoginURL($sUserId, $sPassword, $aOption);
         //return $this->redirectURL(FlexiPlatformHandler::getReferrerURL());
         return $this->redirectURL($sURL);
     }
     //FlexiLogger::error(__METHOD__, "b4");
     if (FlexiConfig::$bRequireEmailVerification && !$oLogin->getIsVerified($sUserId)) {
         $sMessage = flexiT("Sorry, please verify your email first", "first");
         FlexiLogger::error(__METHOD__, $sMessage);
         $this->addMessage($sMessage, "error");
         $this->addMessage("<a href='" . $this->url(array("txtLogin" => $sUserId), "resendVerify") . "'>Click here to resend your verification</a>", "error");
         $aOption["error"] = 1;
         $sURL = FlexiConfig::getLoginHandler()->getLoginURL($sUserId, $sPassword, $aOption);
         //return $this->redirectURL(FlexiPlatformHandler::getReferrerURL());
         return $this->redirectURL($sURL);
     }
     //FlexiLogger::error(__METHOD__, "after");
     $bResult = $oLogin->doLogin($sUserId, $sPassword, $aOption);
     if ($bResult) {
         FlexiLogger::debug(__METHOD__, "login ok");
         $this->oView->addVar("url", $sRedirect);
         return true;
     } else {
         $sMessage = flexiT("Login fail", "first");
         FlexiLogger::error(__METHOD__, $sMessage);
         $this->addMessage($sMessage, "error");
         $aOption["error"] = $sMessage;
         //die("redirect: " . $sRedirect);
         $sURL = FlexiConfig::getLoginHandler()->getLoginURL($sUserId, $sPassword, $aOption);
         //return $this->redirectURL(FlexiPlatformHandler::getReferrerURL());
         return $this->redirectURL($sURL);
     }
 }
Exemplo n.º 9
0
/**
 * return multi-lingual text based on user language
 * @param String $sText
 * @param String $sType: normal,
 *  first: ucfirst,
 *  cap: all capital
 * @return String
 */
function flexiT($sText, $sType = "normal")
{
    $sLang = FlexiConfig::getLoginHandler()->getUserLanguage();
    $sPath = FlexiConfig::$sLanguagePath . "/" . $sLang . ".lang.php";
    $sResult = "";
    if (is_file($sPath)) {
        require $sPath;
        if (isset($aLanguage[$sText])) {
            $sResult = $aLanguage[$sText];
        } else {
            if (isset($aLanguage[strtolower($sText)])) {
                $sResult = $aLanguage[strtolower($sText)];
            } else {
                $sResult = $sText;
            }
        }
    } else {
        $sResult = $sText;
    }
    if ($sType == "first") {
        $sResult = ucfirst($sResult);
    }
    if ($sType == "cap") {
        $sResult = strtoupper($sResult);
    }
    if ($sType == "lower") {
        $sResult = strtolower($sResult);
    }
    return $sResult;
}
Exemplo n.º 10
0
<?php

/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
?>
<div><?php 
echo flexiT("sorry, you do not have the needed credential to access this section", "first");
?>
.</div>
<div><?php 
echo flexiT("have you logged in", "first");
?>
?</div>
<div><a href="<?php 
echo FlexiConfig::getLoginHandler()->getLoginURL();
?>
"><?php 
echo flexiT("please click here to login", "first");
?>
</a></div>