本文整理汇总了PHP中AuthManager::isAuthorized方法的典型用法代码示例。如果您正苦于以下问题:PHP AuthManager::isAuthorized方法的具体用法?PHP AuthManager::isAuthorized怎么用?PHP AuthManager::isAuthorized使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AuthManager
的用法示例。
在下文中一共展示了AuthManager::isAuthorized方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCurrentUserEvents
/**
* Метод загружает события по переданному пользователю. Все эти события могут отражаться в маленьком личном кабинете пользователя.
*
* @param PsUser $user
*/
public function getCurrentUserEvents()
{
$events = array();
if (AuthManager::isAuthorized()) {
$this->profilerStart(__FUNCTION__);
try {
$this->LOGGER->info(' >> Запрошен список события для текущего пользователя');
//Мы должны пробежаться по офисным страницам пользователя, которые поддерживают состояния, и запросить эти состояния
foreach ($this->getUserAcessibleClassInstsFromList(self::LIST_OFFICE) as $office) {
if (!$office instanceof NumerableOfficePage) {
continue;
}
$state = $office->getNumericState();
if ($state) {
$events[$office->getIdent()] = $state;
}
}
$this->LOGGER->info(' << Список событий успешно загружен: ' . array_to_string($events, false));
} catch (Exception $ex) {
$this->LOGGER->info('Произошла ошибка: ' . $ex->getMessage());
$this->profilerStop(false);
throw $ex;
}
$this->profilerStop();
}
return $events;
}
示例2: getTestingResults
/** @return TestingResultDB */
public function getTestingResults($idTesting)
{
if (AuthManager::isAuthorized()) {
return TestingBean::inst()->getTestingResult($idTesting, AuthManager::getUserId());
}
return null;
}
示例3: smarty_modifier_post_meta
function smarty_modifier_post_meta(PostContentProvider $postCP, $news = false)
{
$post = $postCP->getPost();
$postId = $post->getId();
$type = $post->getPostType();
$pp = Handlers::getInstance()->getPostsProcessorByPostType($type);
$rp = Handlers::getInstance()->getRubricsProcessorByPostType($type, false);
$trStateToggle = null;
$rubHref = null;
$commentsHref = null;
$name = null;
if ($news) {
$name = $post->getName();
$name = "<span class=\"name\">{$name}</span>";
}
if (!$news && $post->getPostType() == POST_TYPE_TRAINING && AuthManager::isAuthorized()) {
$trStateToggle = '<a href="#' . $postId . '" title="Изменить состояние урока" class="toggle">Пройден</a>';
}
$rubHref = $rp ? $rp->rubricHref($post->getRubricId(), null, 'rubric') : null;
// if (!$news) {
$commentsCnt = $post->getCommentsCount();
$commentsHref = $pp->postHref($post, "Комментариев: {$commentsCnt}", 'comments', array('class' => 'commentcount'));
// }
if ($name || $trStateToggle || $rubHref || $commentsHref) {
echo '<div class="post_meta">';
echo "{$name} {$trStateToggle} {$rubHref} {$commentsHref}";
echo '</div>';
}
}
示例4: getCurrentDateTimeZone
/** @return DateTimeZone */
public function getCurrentDateTimeZone()
{
if (!isset($this->curTZ)) {
$tzName = AuthManager::isAuthorized() ? PsUser::inst()->getTimezone() : null;
$this->curTZ = $tzName ? $this->getDateTimeZone($tzName) : $this->getDateTimeZone();
}
return $this->curTZ;
}
示例5: processImpl
protected function processImpl(PostArrayAdapter $adapter, $button)
{
$FEEDBACK = FeedbackManager::inst();
/*
* Тема
*/
$theme = $adapter->str(FORM_PARAM_THEME);
$error = UserInputValidator::validateShortText($theme);
if ($error) {
return array(FORM_PARAM_THEME => $error);
}
$theme = UserInputTools::safeShortText($theme);
/*
* Комментарий
*/
$text = $adapter->str(FORM_PARAM_COMMENT);
$error = UserInputValidator::validateLongText($text);
if ($error) {
return array(FORM_PARAM_COMMENT => $error);
}
$text = UserInputTools::safeLongText($text);
/*
* АВТОРИЗОВАН - пользуемся стандартным механизмом добавления сообщения в тред.
* Кодом треда, при этом, является сам пользователь.
*/
if (AuthManager::isAuthorized()) {
$msg = $FEEDBACK->saveMessage(PsUser::inst()->getId(), null, $text, $theme, PsUser::inst());
return new AjaxSuccess($FEEDBACK->buildLeaf($msg));
}
/*
* НЕ АВТОРИЗОВАН - сохраняем сообщение в таблицу анонимных пользователей.
*/
if (!AuthManager::isAuthorized()) {
/*
* Имя пользователя
*/
$name = $adapter->str(FORM_PARAM_NAME);
$error = UserInputValidator::validateShortText($name);
if ($error) {
return array(FORM_PARAM_NAME => $error);
}
$name = UserInputTools::safeShortText($name);
/*
* Контакты
*/
$contacts = $adapter->str(FORM_PARAM_REG_CONTACTS);
if ($contacts) {
$error = UserInputValidator::validateShortText($contacts, false);
if ($error) {
return array(FORM_PARAM_REG_CONTACTS => $error);
}
$contacts = UserInputTools::safeShortText($contacts);
}
$FEEDBACK->saveAnonimousFeedback($name, $contacts, $theme, $text);
return new AjaxSuccess();
}
}
示例6: login
public function login()
{
if (FORM_AdminLoginForm::getInstance()->isValid4Process()) {
$data = FORM_AdminLoginForm::getInstance()->getData();
$login = $data->getLogin();
$passwd = $data->getPassword();
AuthManager::loginAdmin($login, $passwd);
}
return AuthManager::isAuthorized();
}
示例7: getUserPassedLessons
public function getUserPassedLessons()
{
$result = array();
if (AuthManager::isAuthorized()) {
foreach (TRBean::inst()->getPassedLessons(AuthManager::getUserId()) as $id) {
$result["tr{$id}"] = true;
}
}
return $result;
}
示例8: getStructure
public function getStructure()
{
$cacheId = AuthManager::isAuthorized() ? 'a' : 'na' . '_structure';
$structure = PSCache::POSTS()->getFromCache($cacheId);
if (!is_array($structure)) {
PsProfiler::inst(__CLASS__)->start('Build structure');
$structure = $this->getStructureImpl()->toArray();
PsProfiler::inst(__CLASS__)->stop();
PSCache::POSTS()->saveToCache($structure, $cacheId);
}
return $structure;
}
示例9: jsCommon
private function jsCommon()
{
$params['url'] = PsUrl::current();
$params['userId'] = AuthManager::getUserIdOrNull();
$params['isAuthorized'] = AuthManager::isAuthorized();
$params['isDOA'] = PsSettings::DEVMODE_OR_ADMIN();
$params['isLogging'] = PsSettings::DEVMODE_OR_ADMIN();
$params['currentSubmitTimeout'] = ActivityWatcher::getWaitTime();
$params['tzOffset'] = PsTimeZone::inst()->getCurrentDateTimeZone()->getOffset(new DateTime());
$params['marker'] = AuthManager::getUserSessoinMarker();
$params['foldings'] = FoldedStorage::listEntitiesRel();
return $params;
}
示例10: jsCommon
private function jsCommon(PageContext $ctxt)
{
$params['url'] = $ctxt->getRequestUrl();
$params['isPopup'] = $ctxt->isPopupPage();
$params['userId'] = AuthManager::getUserIdOrNull();
$params['isAuthorized'] = AuthManager::isAuthorized();
$params['isDOA'] = PsSettings::DEVMODE_OR_ADMIN();
$params['isLogging'] = PsSettings::DEVMODE_OR_ADMIN();
$params['currentSubmitTimeout'] = ActivityWatcher::getWaitTime();
$params['tzOffset'] = PsTimeZone::inst()->getCurrentDateTimeZone()->getOffset(new DateTime());
$params['marker'] = AuthManager::getUserSessoinMarker();
/* @var $folding FoldedResources */
foreach (Handlers::getInstance()->getFoldingsIndexed() as $unique => $folding) {
$params['foldings'][$unique] = $folding->getResourcesDm()->relDirPath();
}
return $params;
}
示例11: buildLeaf
/**
* Метод строит html листочка на дереве дискуссии:
*
* <li>
* ....
* <ul>
* <li>
* ....
* </li>
* </ul>
* </li>
*
* @param DiscussionMsg $msg
*/
public final function buildLeaf(DiscussionMsg $msg, $simple = false)
{
$msgId = $msg->getId();
$author = $msg->getUser();
$isDeleted = $msg->isDeleted();
$isUserComment = $author->isAuthorised();
$isCanConfirm = !$isUserComment && !$msg->isConfirmed() && !$isDeleted && AuthManager::isAuthorizedAsAdmin();
$notKnown = !$msg->isKnown() && $msg->getUserTo() && $msg->getUserTo()->isIt(PsUser::instOrNull());
$msgUnique = $msg->getUnique();
$threadUnique = $this->SETTINGS->getThreadUnique($msg->getThreadId());
//Мы открываем страницу для показа этого комментария
$liId = RequestArrayAdapter::inst()->str(GET_PARAM_GOTO_MSG) === $msgUnique ? " id=\"{$msgUnique}\"" : '';
//Классы li
$liClasses = array('msg');
if ($isDeleted) {
$liClasses[] = 'deleted';
}
//Классы Comment
$divClasses = array('comment', $msgUnique);
if ($isUserComment) {
$divClasses[] = 'user_comment';
}
if ($isCanConfirm) {
$divClasses[] = 'not_confirmed';
}
//Данные для Comment
$divData['unique'] = $msgUnique;
//Имя пользователя
$userName = $author->getName() . ($isUserComment ? ' (вы)' : '');
//КНОПКИ УПРАВЛЕНИЯ СВЕРХУ
$controlsTop = array();
if (!$simple) {
//Кнопки управления сверху
$controlsTop[] = PsHtml::a(array('href' => '#'), '#');
if (!$msg->isRoot()) {
$controlsTop[] = PsHtml::a(array('href' => '#', 'class' => 'parent'), '↑');
}
}
//Кнопки голосования
if ($this->SETTINGS->isVotable()) {
$userCanVote = AuthManager::isAuthorized() && !$isUserComment;
$votes = VotesManager::inst()->getVotesCount($threadUnique, $msgId);
$likeCtrl = array();
if ($userCanVote) {
$vote = VotesManager::inst()->getUserVotes($threadUnique, $msgId, AuthManager::getUserId());
$likeCtrl[] = PsHtml::a(array('class' => 'like ' . ($vote > 0 ? 'active' : 'clickable')), '+1');
$likeCtrl[] = PsHtml::a(array('class' => 'votes' . ($vote == 0 ? '' : ' clickable') . ($votes == 0 ? '' : ($votes > 0 ? ' green' : ' red'))), abs($votes));
$likeCtrl[] = PsHtml::a(array('class' => 'dislike ' . ($vote < 0 ? 'active' : 'clickable')), '−1');
} else {
$likeCtrl[] = PsHtml::a(array('class' => 'votes' . ($votes == 0 ? '' : ($votes > 0 ? ' green' : ' red'))), abs($votes));
}
$controlsTop[] = PsHtml::span(array('class' => 'vote'), implode('', $likeCtrl));
}
$controlsTop = implode('', $controlsTop);
//КНОПКИ УПРАВЛЕНИЯ СНИЗУ
$controlsBottom = '';
if (!$simple && !$isDeleted) {
$controlsBottom = array();
$controlsBottom['id'] = $msgId;
if ($isCanConfirm) {
$controlsBottom[SmartyFunctions::ACTION_CONFIRM] = 'Принять';
}
if (!$msg->isMaxDeepLevel()) {
$controlsBottom[SmartyFunctions::ACTION_REPLY] = 'Ответить';
}
if ($isUserComment) {
$controlsBottom[SmartyFunctions::ACTION_DELETE] = 'Удалить';
} elseif (AuthManager::isAuthorizedAsAdmin()) {
$controlsBottom[SmartyFunctions::ACTION_DELETE] = 'Удалить (админ)';
}
$controlsBottom = SmartyFunctions::psctrl($controlsBottom);
}
//Собираем параметры в кучу
$params['msg'] = $msg;
$params['new'] = $notKnown;
$params['builder'] = $this;
$params['liId'] = $liId;
$params['liClasses'] = implode(' ', $liClasses);
$params['divClasses'] = implode(' ', $divClasses);
$params['divData'] = PsHtml::data2string($divData);
$params['msgId'] = $msgId;
$params['simple'] = $simple;
$params['avatar'] = $author->getAvatarImg('42x', array('class' => 'small'));
$params['userName'] = $userName;
$params['controlsTop'] = $controlsTop;
$params['controlsBottom'] = $controlsBottom;
//.........这里部分代码省略.........
示例12: isAddCapture
/**
* Метод проверяет, должна ли форма быть защищена с помощью капчи.
* Это выполняется в том случае, если пользователь не авторизован и форма работает с капчей.
*/
private function isAddCapture()
{
return $this->isCheckCapture() && !AuthManager::isAuthorized();
}
示例13: smarty_function_html_input
function smarty_function_html_input($params, Smarty_Internal_Template &$smarty)
{
$adapter = ArrayAdapter::inst($params);
$fieldId = $adapter->get('id');
$label = $adapter->get('label');
$value = $adapter->get('val');
$inputType = $adapter->str('type');
$help = $adapter->str('help');
$RQ = PostArrayAdapter::inst();
$attrs = array();
switch ($inputType) {
case 'hidden':
echo PsHtml::hidden($fieldId, $value);
break;
case 'text':
echo PsHtmlForm::text($label, $fieldId, $RQ->str($fieldId, $value), $attrs, $help);
break;
case 'datetime':
$attrs['class'][] = 'ps-datetime-picker';
echo PsHtmlForm::text($label, $fieldId, $RQ->str($fieldId, $value), $attrs, $help);
break;
case 'pass':
echo PsHtmlForm::password($label, $fieldId, $RQ->str($fieldId));
break;
case 'file':
$label = $adapter->get('label', 'Файл');
$fieldId = $fieldId ? $fieldId : FORM_PARAM_FILE;
echo PsHtmlForm::file($label, $fieldId, $help);
break;
case 'user':
$label = $adapter->get('label', 'Ваше имя');
if (AuthManager::isAuthorized()) {
echo PsHtmlForm::textInfo($label, PsUser::inst()->getName());
} else {
$fieldId = $fieldId ? $fieldId : FORM_PARAM_NAME;
echo PsHtmlForm::text($label, $fieldId, $RQ->str($fieldId), $attrs, $help);
}
break;
case 'textarea':
$label = $adapter->get('label', 'Текст сообщения');
$fieldId = $fieldId ? $fieldId : FORM_PARAM_COMMENT;
$value = $value ? $value : $RQ->str($fieldId, $value);
$maxlen = $adapter->str(array('maxlen', 'maxlength'));
$manual = $adapter->bool('manual');
$codemirror = $adapter->str('codemirror');
echo PsHtmlForm::textarea($label, $fieldId, $value, $maxlen, $manual, $codemirror, $attrs, $help);
break;
case 'submit':
$buttons[] = $label ? $label : 'Отправить';
for ($idx = 0; $idx <= 10; $idx++) {
$button = $adapter->get("label{$idx}");
if ($button) {
$buttons[] = $button;
}
}
$canReset = $adapter->bool('reset');
echo PsHtmlForm::submit($buttons, $canReset);
break;
case 'yesno':
$fieldId = $fieldId ? $fieldId : 'yesno';
$options[] = PsHtml::comboOption(0, 'Нет');
$options[] = PsHtml::comboOption(1, 'Да');
echo PsHtmlForm::select($label, $fieldId, $attrs, $options, 0);
break;
case 'sex':
$value = $value ? $value : $RQ->int($fieldId);
$options[] = PsHtml::comboOption(SEX_GIRL, 'Женский');
$options[] = PsHtml::comboOption(SEX_BOY, 'Мужской');
echo PsHtmlForm::select($label, $fieldId, $attrs, $options, $value);
break;
case 'posttype':
$label = $label ? $label : 'Тип поста';
$fieldId = $fieldId ? $fieldId : FORM_PARAM_POST_TYPE;
$options = array();
/* @var $pr PostsProcessor */
foreach (Handlers::getInstance()->getPostsProcessors() as $type => $pr) {
$title = $pr->postTitle();
$options[] = PsHtml::comboOption($type, "{$title} ({$type})");
}
echo PsHtmlForm::select($label, $fieldId, $attrs, $options);
break;
case 'select':
echo PsHtmlForm::select($label, $fieldId, $attrs, $adapter->arr('options'), $adapter->str('curVal'), $adapter->bool('hasEmpty'), $help);
break;
case 'timezone':
$label = $label ? $label : 'Выберите временную зону';
$tzSelect = PsTimeZone::inst()->zonesSelectHtml();
echo PsHtmlForm::field($label, $tzSelect, $help);
break;
default:
raise_error("Unsupported html input type: [{$inputType}]");
}
}
示例14: buildPanel
public function buildPanel($panelName)
{
$listName = AuthManager::isAuthorized() ? self::LIST_ADMIN : self::LIST_CLIENT;
return new ClientBoxPanel($this->getUserAcessibleClassInstsFromList($listName));
}
示例15: authed
public static final function authed()
{
return AuthManager::isAuthorized();
}