本文整理汇总了PHP中AppContext::get_current_user方法的典型用法代码示例。如果您正苦于以下问题:PHP AppContext::get_current_user方法的具体用法?PHP AppContext::get_current_user怎么用?PHP AppContext::get_current_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppContext
的用法示例。
在下文中一共展示了AppContext::get_current_user方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_module_map
private function get_module_map($auth_mode)
{
$lang = LangLoader::get('common', 'bugtracker');
$config = BugtrackerConfig::load();
$current_user = AppContext::get_current_user();
$link = new SitemapLink($lang['module_title'], BugtrackerUrlBuilder::home(), Sitemap::FREQ_DEFAULT, Sitemap::PRIORITY_MAX);
$module_map = new ModuleMap($link, 'bugtracker');
if ($auth_mode == Sitemap::AUTH_PUBLIC) {
$this_auth = Authorizations::check_auth(RANK_TYPE, User::VISITOR_LEVEL, $config->get_authorizations(), BugtrackerAuthorizationsService::READ_AUTHORIZATIONS);
} else {
if ($auth_mode == Sitemap::AUTH_USER) {
if ($current_user->get_level() == User::ADMIN_LEVEL) {
$this_auth = true;
} else {
$this_auth = Authorizations::check_auth(RANK_TYPE, $current_user->get_level(), $config->get_authorizations(), BugtrackerAuthorizationsService::READ_AUTHORIZATIONS);
}
}
}
if ($this_auth) {
$module_map->add(new SitemapLink($lang['titles.unsolved'], BugtrackerUrlBuilder::unsolved()));
$module_map->add(new SitemapLink($lang['titles.solved'], BugtrackerUrlBuilder::solved()));
if ($config->is_roadmap_enabled() && $config->get_versions()) {
$module_map->add(new SitemapLink($lang['titles.roadmap'], BugtrackerUrlBuilder::roadmap()));
}
$module_map->add(new SitemapLink($lang['titles.stats'], BugtrackerUrlBuilder::stats()));
}
return $module_map;
}
示例2: build_view
public function build_view(HTTPRequestCustom $request)
{
$authorized_categories = CalendarService::get_authorized_categories(Category::ROOT_CATEGORY);
$condition = 'WHERE approved = 0
AND parent_id = 0
AND id_category IN :authorized_categories
' . (!CalendarAuthorizationsService::check_authorizations()->moderation() ? ' AND event_content.author_id = :user_id' : '');
$parameters = array('authorized_categories' => $authorized_categories, 'user_id' => AppContext::get_current_user()->get_id());
$page = AppContext::get_request()->get_getint('page', 1);
$pagination = $this->get_pagination($condition, $parameters, $page);
$result = PersistenceContext::get_querier()->select('SELECT *
FROM ' . CalendarSetup::$calendar_events_table . ' event
LEFT JOIN ' . CalendarSetup::$calendar_events_content_table . ' event_content ON event_content.id = event.content_id
LEFT JOIN ' . DB_TABLE_MEMBER . ' member ON member.user_id = event_content.author_id
LEFT JOIN ' . DB_TABLE_COMMENTS_TOPIC . ' com ON com.id_in_module = event.id_event AND com.module_id = \'calendar\'
' . $condition . '
ORDER BY start_date DESC
LIMIT :number_items_per_page OFFSET :display_from', array_merge($parameters, array('number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from())));
$this->events_view->put_all(array('C_PAGINATION' => $pagination->has_several_pages(), 'C_EVENTS' => $result->get_rows_count() > 0, 'C_PENDING_PAGE' => true, 'PAGINATION' => $pagination->display()));
while ($row = $result->fetch()) {
$event = new CalendarEvent();
$event->set_properties($row);
$this->events_view->assign_block_vars('event', $event->get_array_tpl_vars());
}
$result->dispose();
$this->tpl->put_all(array('EVENTS' => $this->events_view, 'C_PENDING_PAGE' => true));
return $this->tpl;
}
示例3: init
private function init()
{
$this->current_user = AppContext::get_current_user();
$this->lang = LangLoader::get('common', 'guestbook');
$this->view = new FileTemplate('guestbook/GuestbookController.tpl');
$this->view->add_lang($this->lang);
}
示例4: build_view
public function build_view()
{
$now = new Date();
$authorized_categories = NewsService::get_authorized_categories(Category::ROOT_CATEGORY);
$news_config = NewsConfig::load();
$condition = 'WHERE id_category IN :authorized_categories
' . (!NewsAuthorizationsService::check_authorizations()->moderation() ? ' AND author_user_id = :user_id' : '') . '
AND (approbation_type = 0 OR (approbation_type = 2 AND (start_date > :timestamp_now OR (end_date != 0 AND end_date < :timestamp_now))))';
$parameters = array('authorized_categories' => $authorized_categories, 'user_id' => AppContext::get_current_user()->get_id(), 'timestamp_now' => $now->get_timestamp());
$page = AppContext::get_request()->get_getint('page', 1);
$pagination = $this->get_pagination($condition, $parameters, $page);
$result = PersistenceContext::get_querier()->select('SELECT news.*, member.*
FROM ' . NewsSetup::$news_table . ' news
LEFT JOIN ' . DB_TABLE_MEMBER . ' member ON member.user_id = news.author_user_id
' . $condition . '
ORDER BY top_list_enabled DESC, news.creation_date DESC
LIMIT :number_items_per_page OFFSET :display_from', array_merge($parameters, array('number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from())));
$number_columns_display_news = $news_config->get_number_columns_display_news();
$this->tpl->put_all(array('C_DISPLAY_BLOCK_TYPE' => $news_config->get_display_type() == NewsConfig::DISPLAY_BLOCK, 'C_DISPLAY_LIST_TYPE' => $news_config->get_display_type() == NewsConfig::DISPLAY_LIST, 'C_DISPLAY_CONDENSED_CONTENT' => $news_config->get_display_condensed_enabled(), 'C_COMMENTS_ENABLED' => $news_config->get_comments_enabled(), 'C_NEWS_NO_AVAILABLE' => $result->get_rows_count() == 0, 'C_PENDING_NEWS' => true, 'C_PAGINATION' => $pagination->has_several_pages(), 'PAGINATION' => $pagination->display(), 'C_SEVERAL_COLUMNS' => $number_columns_display_news > 1, 'NUMBER_COLUMNS' => $number_columns_display_news));
while ($row = $result->fetch()) {
$news = new News();
$news->set_properties($row);
$this->tpl->assign_block_vars('news', $news->get_array_tpl_vars());
$this->build_sources_view($news);
}
$result->dispose();
}
示例5: get_right_controller_regarding_authorizations
public function get_right_controller_regarding_authorizations()
{
if (AppContext::get_current_user()->check_level(User::MEMBER_LEVEL)) {
AppContext::get_response()->redirect(Environment::get_home_page());
}
return $this;
}
示例6: get_user_timezone
public static function get_user_timezone()
{
if (self::$user_timezone == null) {
self::$user_timezone = new DateTimeZone(AppContext::get_current_user()->get_timezone());
}
return self::$user_timezone;
}
示例7: execute
public function execute(HTTPRequestCustom $request)
{
$lang = LangLoader::get('common');
$is_admin = AppContext::get_current_user()->check_level(User::ADMIN_LEVEL);
$number_admins = UserService::count_admin_members();
$suggestions = array();
try {
$result = PersistenceContext::get_querier()->select("SELECT user_id, display_name, level, groups FROM " . DB_TABLE_MEMBER . " WHERE display_name LIKE '" . str_replace('*', '%', $request->get_value('value', '')) . "%'");
while ($row = $result->fetch()) {
$user_group_color = User::get_group_color($row['groups'], $row['level']);
$suggestion = '';
if ($is_admin) {
$edit_link = new LinkHTMLElement(UserUrlBuilder::edit_profile($row['user_id']), '', array('title' => $lang['edit']), 'fa fa-edit');
if ($row['level'] != User::ADMIN_LEVEL || $row['level'] == User::ADMIN_LEVEL && $number_admins > 1) {
$delete_link = new LinkHTMLElement(AdminMembersUrlBuilder::delete($row['user_id']), '', array('title' => $lang['delete'], 'data-confirmation' => 'delete-element'), 'fa fa-delete');
} else {
$delete_link = new LinkHTMLElement('', '', array('title' => $lang['delete'], 'onclick' => 'return false;'), 'fa fa-delete icon-disabled');
}
$suggestion .= $edit_link->display() . ' ' . $delete_link->display() . ' ';
}
$profile_link = new LinkHTMLElement(UserUrlBuilder::profile($row['user_id'])->rel(), $row['display_name'], array('style' => !empty($user_group_color) ? 'color:' . $user_group_color : ''), UserService::get_level_class($row['level']));
$suggestion .= $profile_link->display();
$suggestions[] = $suggestion;
}
$result->dispose();
} catch (Exception $e) {
}
return new JSONResponse(array('suggestions' => $suggestions));
}
示例8: build_form
public function build_form()
{
$form = new HTMLForm(__CLASS__);
// Fieldset to configure path
$fieldsetPath = new FormFieldsetHTML('wpimport-path', $this->lang['wpimport.fieldset-path']);
$form->add_fieldset($fieldsetPath);
$fieldsetPath->add_field(new FormFieldTextEditor('phpboostpath', $this->lang['wpimport.phpboostpath'], realpath(__DIR__ . '/../../')));
$fieldsetPath->add_field(new FormFieldTextEditor('wppath', $this->lang['wpimport.wppath'], realpath(__DIR__ . '/../../../'), array(), array(new FormFieldConstraintWordPressPath($this->lang['constraint.wp-path']))));
// Fieldset to configure which data are import
$fieldsetImporter = new FormFieldsetHTML('wpimport-importer', $this->lang['wpimport.fieldset-importer']);
$form->add_fieldset($fieldsetImporter);
$importers = $this->listImporters();
foreach ($importers as $importer) {
$fieldsetImporter->add_field(new FormFieldCheckbox('importer_' . $importer['name'], $importer['name'], FormFieldCheckbox::UNCHECKED, array('description' => $this->lang['wpimport.description'] . ': ' . utf8_decode($importer['description']) . '<br />' . $this->lang['wpimport.version'] . ': ' . $importer['version'])));
}
// Fieldset to confgure options
$fieldsetOptions = new FormFieldsetHTML('wpimport-options', $this->lang['wpimport.fieldset-options']);
$form->add_fieldset($fieldsetOptions);
// Default Author
$fieldsetOptions->add_field(new FormFieldAjaxUserAutoComplete('default_author', $this->lang['wpimport.default_author'], AppContext::get_current_user()->get_login(), array('description' => $this->lang['wpimport.default_author.decription']), array(new FormFieldConstraintUserExist($this->lang['wpimport.default_author.error_user_exist']))));
// Default Image
$fieldsetOptions->add_field(new FormFieldUploadFile('default_cat_image', $this->lang['wpimport.default_cat_image'], $this->getDefaultConfiguration()['PHPBOOST_CAT_IMAGE'], array('description' => $this->lang['wpimport.default_cat_image.description'])));
$fieldsetOptions->add_field(new FormFieldTextEditor('import_location', $this->lang['wpimport.import_location'], $this->getDefaultConfiguration()['FILESYSTEM_IMPORT_LOCATION'], array('description' => $this->lang['wpimport.import_location.description'])));
$this->submit_button = new FormButtonSubmit($this->lang['wpimport.submit_configuration'], 'submit_configuration');
$form->add_button($this->submit_button);
$form->add_button(new FormButtonReset($this->lang['wpimport.reset']));
$this->form = $form;
}
示例9: get_search_request
public function get_search_request($args)
{
$search = $args['search'];
$weight = isset($args['weight']) && is_numeric($args['weight']) ? $args['weight'] : 1;
require_once PATH_TO_ROOT . '/pages/pages_defines.php';
$categories = PagesCategoriesCache::load()->get_categories();
$unauth_cats = '';
if (!AppContext::get_current_user()->check_auth(PagesConfig::load()->get_authorizations(), READ_PAGE)) {
$unauth_cats .= '0,';
}
foreach ($categories as $id => $cat) {
if (!AppContext::get_current_user()->check_auth($cat['auth'], READ_PAGE)) {
$unauth_cats .= $id . ',';
}
}
$unauth_cats = !empty($unauth_cats) ? " AND p.id_cat NOT IN (" . trim($unauth_cats, ',') . ")" : '';
$results = array();
$result = PersistenceContext::get_querier()->select("SELECT " . $args['id_search'] . " AS `id_search`,\r\n\t\tp.id AS `id_content`,\r\n\t\tp.title AS `title`,\r\n\t\t( 2 * FT_SEARCH_RELEVANCE(p.title, '" . $args['search'] . "') + FT_SEARCH_RELEVANCE(p.contents, '" . $args['search'] . "') ) / 3 * " . $weight . " AS `relevance`,\r\n\t\tCONCAT('" . PATH_TO_ROOT . "/pages/pages.php?title=',p.encoded_title) AS `link`,\r\n\t\tp.auth AS `auth`\r\n\t\tFROM " . PREFIX . "pages p\r\n\t\tWHERE ( FT_SEARCH(title, '" . $args['search'] . "') OR FT_SEARCH(contents, '" . $args['search'] . "') )" . $unauth_cats . "\r\n\t\tLIMIT 100 OFFSET 0");
while ($row = $result->fetch()) {
if (!empty($row['auth'])) {
$auth = unserialize($row['auth']);
if (!AppContext::get_current_user()->check_auth($auth, READ_PAGE)) {
unset($row['auth']);
array_push($results, $row);
}
} else {
unset($row['auth']);
array_push($results, $row);
}
}
$result->dispose();
return $results;
}
示例10: get_right_controller_regarding_authorizations
public final function get_right_controller_regarding_authorizations()
{
if (!AppContext::get_current_user()->is_admin()) {
return new UserLoginController(UserLoginController::ADMIN_LOGIN, substr(REWRITED_SCRIPT, strlen(GeneralConfig::load()->get_site_path())));
}
return $this;
}
示例11: check_authorizations
private function check_authorizations()
{
$article = $this->get_article();
$not_authorized = !ArticlesAuthorizationsService::check_authorizations($article->get_id_category())->write() && (!ArticlesAuthorizationsService::check_authorizations($article->get_id_category())->moderation() && $article->get_author_user()->get_id() != AppContext::get_current_user()->get_id());
switch ($article->get_publishing_state()) {
case Article::PUBLISHED_NOW:
if (!ArticlesAuthorizationsService::check_authorizations()->read() && $not_authorized) {
$error_controller = PHPBoostErrors::user_not_authorized();
DispatchManager::redirect($error_controller);
}
break;
case Article::NOT_PUBLISHED:
if ($not_authorized) {
$error_controller = PHPBoostErrors::user_not_authorized();
DispatchManager::redirect($error_controller);
}
break;
case Article::PUBLISHED_DATE:
if (!$article->is_published() && $not_authorized) {
$error_controller = PHPBoostErrors::user_not_authorized();
DispatchManager::redirect($error_controller);
}
break;
default:
$error_controller = PHPBoostErrors::unexisting_page();
DispatchManager::redirect($error_controller);
break;
}
}
示例12: get_content
public function get_content()
{
$tpl = new FileTemplate('newsletter/newsletter_mini.tpl');
$tpl->add_lang(LangLoader::get('common', 'newsletter'));
$tpl->put('USER_MAIL', AppContext::get_current_user()->get_email());
return $tpl;
}
示例13: build_view
public function build_view(HTTPRequestCustom $request)
{
$authorized_categories = FaqService::get_authorized_categories(Category::ROOT_CATEGORY);
$mode = $request->get_getstring('sort', FaqUrlBuilder::DEFAULT_SORT_MODE);
$field = $request->get_getstring('field', FaqUrlBuilder::DEFAULT_SORT_FIELD);
$sort_mode = $mode == 'asc' ? 'ASC' : 'DESC';
switch ($field) {
case 'question':
$sort_field = FaqQuestion::SORT_ALPHABETIC;
break;
default:
$sort_field = FaqQuestion::SORT_DATE;
break;
}
$result = PersistenceContext::get_querier()->select('SELECT *
FROM ' . FaqSetup::$faq_table . ' faq
LEFT JOIN ' . DB_TABLE_MEMBER . ' member ON member.user_id = faq.author_user_id
WHERE approved = 0
AND faq.id_category IN :authorized_categories
' . (!FaqAuthorizationsService::check_authorizations()->moderation() ? ' AND faq.author_user_id = :user_id' : '') . '
ORDER BY ' . $sort_field . ' ' . $sort_mode, array('authorized_categories' => $authorized_categories, 'user_id' => AppContext::get_current_user()->get_id()));
$this->tpl->put_all(array('C_QUESTIONS' => $result->get_rows_count() > 0, 'C_PENDING' => true, 'C_MORE_THAN_ONE_QUESTION' => $result->get_rows_count() > 1, 'C_DISPLAY_TYPE_ANSWERS_HIDDEN' => FaqConfig::load()->is_display_type_answers_hidden(), 'QUESTIONS_NUMBER' => $result->get_rows_count()));
while ($row = $result->fetch()) {
$faq_question = new FaqQuestion();
$faq_question->set_properties($row);
$this->tpl->assign_block_vars('questions', $faq_question->get_array_tpl_vars());
}
$result->dispose();
$this->build_sorting_form($field, $mode);
}
示例14: check_auth
public function check_auth()
{
if ($this->id == UserAccountsConfig::load()->get_default_lang()) {
return true;
}
return AppContext::get_current_user()->check_auth($this->authorizations, self::ACCES_LANG);
}
示例15: build_view
private function build_view($group_id)
{
if (!empty($group_id)) {
$group = $this->groups_cache->get_group($group_id);
$this->view->put_all(array('C_ADMIN' => AppContext::get_current_user()->check_level(User::ADMIN_LEVEL), 'U_ADMIN_GROUPS' => TPL_PATH_TO_ROOT . '/admin/admin_groups.php?id=' . $group_id, 'GROUP_NAME' => $group['name']));
} else {
$this->view->put_all(array('GROUP_NAME' => $this->lang['groups']));
}
$user_accounts_config = UserAccountsConfig::load();
$number_member = 0;
foreach ($this->get_members_group($group_id) as $user_id) {
if (!empty($user_id)) {
$user = PersistenceContext::get_querier()->select('SELECT
member.display_name, member.level, member.groups, member.warning_percentage, member.delay_banned, ext_field.user_avatar
FROM ' . DB_TABLE_MEMBER . ' member
LEFT JOIN ' . DB_TABLE_MEMBER_EXTENDED_FIELDS . ' ext_field ON ext_field.user_id = member.user_id
WHERE member.user_id = :user_id
', array('user_id' => $user_id))->fetch();
if (!empty($user)) {
//Avatar
$user_avatar = !empty($user['user_avatar']) ? Url::to_rel($user['user_avatar']) : ($user_accounts_config->is_default_avatar_enabled() ? Url::to_rel('/templates/' . AppContext::get_current_user()->get_theme() . '/images/' . $user_accounts_config->get_default_avatar_name()) : '');
$group_color = User::get_group_color($user['groups'], $user['level']);
$this->view->assign_block_vars('members_list', array('C_AVATAR' => $user['user_avatar'] || $user_accounts_config->is_default_avatar_enabled(), 'C_GROUP_COLOR' => !empty($group_color), 'PSEUDO' => $user['display_name'], 'LEVEL' => $user['warning_percentage'] < '100' || time() - $user['delay_banned'] < 0 ? UserService::get_level_lang($user['level']) : $this->lang['banned'], 'LEVEL_CLASS' => UserService::get_level_class($user['level']), 'GROUP_COLOR' => $group_color, 'U_PROFILE' => UserUrlBuilder::profile($user_id)->rel(), 'U_AVATAR' => $user_avatar));
$number_member++;
}
}
}
$this->view->put_all(array('C_NOT_MEMBERS' => $number_member == 0, 'SELECT_GROUP' => $this->build_form($group_id)->display()));
}