本文整理汇总了PHP中Kwf_Setup::hasAuthedUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Kwf_Setup::hasAuthedUser方法的具体用法?PHP Kwf_Setup::hasAuthedUser怎么用?PHP Kwf_Setup::hasAuthedUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kwf_Setup
的用法示例。
在下文中一共展示了Kwf_Setup::hasAuthedUser方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSessionToken
public static function getSessionToken()
{
if (!Kwf_Setup::hasAuthedUser()) {
return null;
}
$ns = new Kwf_Session_Namespace('sessionToken');
if (!$ns->token) {
$ns->token = md5(microtime() . mt_rand());
}
return $ns->token;
}
示例2: isLoggedIn
public function isLoggedIn()
{
if (Kwf_Setup::hasAuthedUser()) {
$user = Zend_Registry::get('userModel')->getAuthedUser();
if (!$user) {
return false;
}
if (!$this->_getSetting('validUserRoles')) {
return true;
}
if (in_array($user->role, $this->_getSetting('validUserRoles'))) {
return true;
}
}
return false;
}
示例3: getTargetLanguage
public function getTargetLanguage()
{
if (PHP_SAPI == 'cli' || !$this->_useUserLanguage) {
return $this->getWebCodeLanguage();
}
//shortcut
if (count($this->getLanguages()) == 1) {
return $this->getWebCodeLanguage();
}
if (!Kwf_Setup::hasAuthedUser()) {
return $this->getWebCodeLanguage();
} else {
if ($this->_authedUserTargetLanguageCache) {
return $this->_authedUserTargetLanguageCache;
}
//TODO: this ALWAYS requires a db connection, should be saved in session
$userModel = Kwf_Registry::get('userModel');
$authedUser = $userModel->getAuthedUser();
if (!isset($userModel->getAuthedUser()->language) || !($userLanguage = $userModel->getAuthedUser()->language) || !in_array($userLanguage, $this->getLanguages())) {
$this->_authedUserTargetLanguageCache = $this->getWebCodeLanguage();
return $this->_authedUserTargetLanguageCache;
}
$this->_authedUserTargetLanguageCache = $userLanguage;
return $this->_authedUserTargetLanguageCache;
}
}
示例4: _isLoggedIn
protected function _isLoggedIn()
{
return Kwf_Setup::hasAuthedUser();
}
示例5: _renderPass2
/**
* Render components (ie. expand <kwc ...>)
*
* Pass 1 for content that can be stored in fullPage cache,
* 2 for everything else. 2 includes 1, so calling just with 2 also works
* @param string render content
*/
protected function _renderPass2($ret, &$hasDynamicParts = false)
{
//execute all plugins that where added in pass 1
$ret = $this->_findAndExecutePlugins($ret, self::PLUGIN_TYPE_USECACHE, $hasDynamicParts);
$ret = $this->_findAndExecutePlugins($ret, self::PLUGIN_TYPE_BEFORE, $hasDynamicParts);
$ret = $this->_findAndExecutePlugins($ret, self::PLUGIN_TYPE_REPLACE, $hasDynamicParts);
$ret = $this->_findAndExecuteUseCacheDynamic($ret, $hasDynamicParts);
static $benchmarkEnabled;
if (!isset($benchmarkEnabled)) {
$benchmarkEnabled = Kwf_Benchmark::isEnabled();
}
$offset = 0;
while ($target = $this->_getNextRenderTarget($ret, 2, $offset)) {
if ($benchmarkEnabled) {
$startTime = microtime(true);
}
if ($target['type'] == 'dynamic' && $target['config']['class'] == 'Kwf_Component_Dynamic_SessionToken' && !Kwf_Setup::hasAuthedUser()) {
$hasDynamicParts = true;
//yes, this is cheating, but a very common case that's worth optimizing using this hack
$ret = substr($ret, 0, $target['start']) . '' . substr($ret, $target['end'] + 1);
continue;
}
$helper = $this->_getHelper($target['type']);
$statType = null;
$content = null;
if ($this->_enableCache && $target['isCacheable']) {
$content = $this->_cacheLoad($target['componentId'], $target['type'], $target['value']);
}
if (!is_null($content)) {
//cache hit
$statType = 'hit';
//look for UseViewCache plugin in $content
if ($p = $this->_findSinglePlugin(self::PLUGIN_TYPE_USECACHE, $content)) {
$hasDynamicParts = true;
if (!$p['plugin']->useViewCache($this)) {
//re-render, without <pluginC
$content = $this->_renderUncached($target['componentId'], $target['type'], $target['config']);
} else {
//continue with content
$content = $p['content'];
}
} else {
//execute replace and before plugin
if ($p = $this->_findSinglePlugin(self::PLUGIN_TYPE_REPLACE, $content)) {
$hasDynamicParts = true;
$r = $p['plugin']->replaceOutput($this);
if ($r !== false) {
$content = $r;
} else {
$content = $p['content'];
}
}
$content = $this->_findAndExecutePlugins($content, self::PLUGIN_TYPE_BEFORE, $hasDynamicParts);
}
$content = $this->_findAndExecuteUseCacheDynamic($content, $hasDynamicParts);
} else {
if ($this->_enableCache && $target['isCacheable']) {
//cache miss
$statType = 'miss';
$content = $this->_renderAndCache($target['componentId'], $target['type'], $target['value'], $target['config'], false);
} else {
$hasDynamicParts = true;
//view cache disabled
$statType = 'noviewcache';
$content = $this->_renderUncached($target['componentId'], $target['type'], $target['config']);
}
}
$content = $helper->renderCached($content, $target['componentId'], $target['config']);
$ret = substr($ret, 0, $target['start']) . $content . substr($ret, $target['end'] + 1);
if ($statType) {
if ($benchmarkEnabled) {
Kwf_Benchmark::count("rendered {$statType}", $target['statId']);
}
Kwf_Benchmark::countLog('render-' . $statType);
}
if ($benchmarkEnabled) {
Kwf_Benchmark::subCheckpoint($target['componentId'] . ' ' . $target['type'], microtime(true) - $startTime);
}
}
//execute Render Cached Dynamic, used eg for callback link modifier in componentLink
while (($start = strpos($ret, '<rcd ')) !== false) {
$hasDynamicParts = true;
$startEnd = strpos($ret, '>', $start);
$args = explode(' ', substr($ret, $start + 5, $startEnd - $start - 5));
$end = strpos($ret, '</rcd ' . $args[0] . '>');
$content = substr($ret, $startEnd + 1, $end - $startEnd - 1);
if ($benchmarkEnabled) {
$startTime = microtime(true);
}
$componentId = $args[0];
$type = $args[1];
$settings = json_decode($args[2], true);
$content = $this->_getHelper($type)->renderCachedDynamic($content, $componentId, $settings);
//.........这里部分代码省略.........