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;
 }
    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;
    }
 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);
 }
    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();
    }
 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
0
 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;
 }
 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() . '&nbsp;' . $delete_link->display() . '&nbsp;';
             }
             $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));
 }
 private function init()
 {
     $this->current_user = AppContext::get_current_user();
     $this->lang = LangLoader::get('common', 'shoutbox');
     $this->view = new FileTemplate('shoutbox/ShoutboxHomeController.tpl');
     $this->view->add_lang($this->lang);
 }
 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;
 }
Пример #10
0
 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;
 }
Пример #11
0
 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;
 }
 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;
     }
 }
 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;
 }
    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);
    }
Пример #15
0
 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);
 }
    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()));
    }
 private function init()
 {
     $this->user = AppContext::get_current_user();
     $this->tpl = new FileTemplate('user/UserMessagesController.tpl');
     $this->lang = LangLoader::get('user-common');
     $this->tpl->add_lang($this->lang);
 }
 public function execute(HTTPRequestCustom $request)
 {
     $id = $request->get_getint('id', 0);
     if (!empty($id) && AppContext::get_current_user()->check_level(User::MEMBER_LEVEL)) {
         try {
             $this->downloadfile = DownloadService::get_downloadfile('WHERE download.id = :id', array('id' => $id));
         } catch (RowNotFoundException $e) {
             $error_controller = PHPBoostErrors::unexisting_page();
             DispatchManager::redirect($error_controller);
         }
     }
     if ($this->downloadfile !== null && $this->downloadfile->is_visible()) {
         if (!PersistenceContext::get_querier()->row_exists(PREFIX . 'events', 'WHERE id_in_module=:id_in_module AND module=\'download\' AND current_status = 0', array('id_in_module' => $this->downloadfile->get_id()))) {
             $contribution = new Contribution();
             $contribution->set_id_in_module($this->downloadfile->get_id());
             $contribution->set_entitled(StringVars::replace_vars(LangLoader::get_message('contribution.deadlink', 'common'), array('link_name' => $this->downloadfile->get_name())));
             $contribution->set_fixing_url(DownloadUrlBuilder::edit($this->downloadfile->get_id())->relative());
             $contribution->set_description(LangLoader::get_message('contribution.deadlink_explain', 'common'));
             $contribution->set_poster_id(AppContext::get_current_user()->get_id());
             $contribution->set_module('download');
             $contribution->set_type('alert');
             $contribution->set_auth(Authorizations::capture_and_shift_bit_auth(DownloadService::get_categories_manager()->get_heritated_authorizations($this->downloadfile->get_id_category(), Category::MODERATION_AUTHORIZATIONS, Authorizations::AUTH_CHILD_PRIORITY), Category::MODERATION_AUTHORIZATIONS, Contribution::CONTRIBUTION_AUTH_BIT));
             ContributionService::save_contribution($contribution);
         }
         DispatchManager::redirect(new UserContributionSuccessController());
     } else {
         $error_controller = PHPBoostErrors::unexisting_page();
         DispatchManager::redirect($error_controller);
     }
 }
    private function build_table()
    {
        $table_model = new SQLHTMLTableModel(DownloadSetup::$download_table, 'table', array(new HTMLTableColumn(LangLoader::get_message('form.name', 'common'), 'name'), new HTMLTableColumn(LangLoader::get_message('category', 'categories-common'), 'id_category'), new HTMLTableColumn(LangLoader::get_message('author', 'common'), 'display_name'), new HTMLTableColumn(LangLoader::get_message('form.date.creation', 'common'), 'creation_date'), new HTMLTableColumn(LangLoader::get_message('status', 'common'), 'approbation_type'), new HTMLTableColumn('')), new HTMLTableSortingRule('creation_date', HTMLTableSortingRule::DESC));
        $table = new HTMLTable($table_model);
        $table_model->set_caption($this->lang['download.management']);
        $results = array();
        $result = $table_model->get_sql_results('download
			LEFT JOIN ' . DB_TABLE_COMMENTS_TOPIC . ' com ON com.id_in_module = download.id AND com.module_id = \'download\'
			LEFT JOIN ' . DB_TABLE_AVERAGE_NOTES . ' notes ON notes.id_in_module = download.id AND notes.module_name = \'download\'
			LEFT JOIN ' . DB_TABLE_NOTE . ' note ON note.id_in_module = download.id AND note.module_name = \'download\' AND note.user_id = ' . AppContext::get_current_user()->get_id() . '
			LEFT JOIN ' . DB_TABLE_MEMBER . ' member ON member.user_id = download.author_user_id', array('*', 'download.id'));
        foreach ($result as $row) {
            $downloadfile = new DownloadFile();
            $downloadfile->set_properties($row);
            $category = $downloadfile->get_category();
            $user = $downloadfile->get_author_user();
            $edit_link = new LinkHTMLElement(DownloadUrlBuilder::edit($downloadfile->get_id()), '', array('title' => LangLoader::get_message('edit', 'common')), 'fa fa-edit');
            $delete_link = new LinkHTMLElement(DownloadUrlBuilder::delete($downloadfile->get_id()), '', array('title' => LangLoader::get_message('delete', 'common'), 'data-confirmation' => 'delete-element'), 'fa fa-delete');
            $user_group_color = User::get_group_color($user->get_groups(), $user->get_level(), true);
            $author = $user->get_id() !== User::VISITOR_LEVEL ? new LinkHTMLElement(UserUrlBuilder::profile($user->get_id()), $user->get_display_name(), !empty($user_group_color) ? array('style' => 'color: ' . $user_group_color) : array(), UserService::get_level_class($user->get_level())) : $user->get_display_name();
            $results[] = new HTMLTableRow(array(new HTMLTableRowCell(new LinkHTMLElement(DownloadUrlBuilder::display($category->get_id(), $category->get_rewrited_name(), $downloadfile->get_id(), $downloadfile->get_rewrited_name()), $downloadfile->get_name()), 'left'), new HTMLTableRowCell(new LinkHTMLElement(DownloadUrlBuilder::display_category($category->get_id(), $category->get_rewrited_name()), $category->get_name())), new HTMLTableRowCell($author), new HTMLTableRowCell($downloadfile->get_creation_date()->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE)), new HTMLTableRowCell($downloadfile->get_status()), new HTMLTableRowCell($edit_link->display() . $delete_link->display())));
        }
        $table->set_rows($table_model->get_number_of_matching_rows(), $results);
        $this->view->put('table', $table->display());
    }
 private function check_authorizations()
 {
     if (!$this->faq_question->is_authorized_to_delete() || AppContext::get_current_user()->is_readonly()) {
         return false;
     } else {
         return true;
     }
 }
 protected function create_view()
 {
     $columns_disabled = ThemesManager::get_theme(AppContext::get_current_user()->get_theme())->get_columns_disabled();
     $columns_disabled->set_disable_right_columns(true);
     $columns_disabled->set_disable_left_columns(true);
     $columns_disabled->set_disable_top_central(true);
     $columns_disabled->set_disable_bottom_central(true);
     $this->view = new FileTemplate('user/UserError403Controller.tpl');
 }
 private static function find_desc_ini_file($theme_id)
 {
     $desc_ini_folder = PATH_TO_ROOT . '/templates/' . $theme_id . '/lang/';
     $desc_ini_file = $desc_ini_folder . AppContext::get_current_user()->get_locale() . '/desc.ini';
     if (file_exists($desc_ini_file)) {
         return $desc_ini_file;
     }
     throw new IOException('Theme "' . $theme_id . '" desc.ini not found in' . '/' . $theme_id . '/lang/');
 }
 public function get_lang()
 {
     if ($this->lang !== null) {
         return $this->lang;
     } else {
         // TODO change for a new function
         return substr(AppContext::get_current_user()->get_locale(), 2);
     }
 }
 public function __construct($id_comment, $topic_path)
 {
     $this->id_comment = $id_comment;
     $this->user = AppContext::get_current_user();
     $this->lang = LangLoader::get('main');
     $this->topic_path = $topic_path;
     $this->comments_lang = LangLoader::get('comments-common');
     $this->comments_configuration = CommentsConfig::load();
 }
Пример #25
0
 public function set_avatar($avatar)
 {
     $user_accounts_config = UserAccountsConfig::load();
     if (empty($avatar)) {
         $this->avatar = $user_accounts_config->is_default_avatar_enabled() ? PATH_TO_ROOT . '/templates/' . AppContext::get_current_user()->get_theme() . '/images/' . $user_accounts_config->get_default_avatar_name() : '';
     } else {
         $this->avatar = $avatar;
     }
 }
 public function execute(HTTPRequestCustom $request)
 {
     $id = $request->get_int('id', 0);
     $page = $request->get_value('page', '');
     $filter = $request->get_value('filter', '');
     $filter_id = $request->get_value('filter_id', '');
     //Add filter
     BugtrackerService::add_filter(array('user_id' => AppContext::get_current_user()->get_id(), 'page' => $page, 'filters' => $filter, 'filters_ids' => $filter_id));
     AppContext::get_response()->redirect($request->get_url_referrer() ? $request->get_url_referrer() : BugtrackerUrlBuilder::unsolved(), LangLoader::get_message('success.add.filter', 'common', 'bugtracker'));
 }
Пример #27
0
 public static function get_authorized_categories($current_id_category)
 {
     $search_category_children_options = new SearchCategoryChildrensOptions();
     $search_category_children_options->add_authorizations_bits(Category::READ_AUTHORIZATIONS);
     if (AppContext::get_current_user()->is_guest()) {
         $search_category_children_options->set_allow_only_member_level_authorizations(ArticlesConfig::load()->are_descriptions_displayed_to_guests());
     }
     $categories = self::get_categories_manager()->get_childrens($current_id_category, $search_category_children_options, true);
     return array_keys($categories);
 }
 private function check_authorizations()
 {
     if (!$this->downloadfile->is_authorized_to_delete()) {
         $error_controller = PHPBoostErrors::user_not_authorized();
         DispatchManager::redirect($error_controller);
     }
     if (AppContext::get_current_user()->is_readonly()) {
         $error_controller = PHPBoostErrors::user_in_read_only();
         DispatchManager::redirect($error_controller);
     }
 }
 private function check_authorizations(ShoutboxMessage $message)
 {
     if (!$message->is_authorized_to_delete()) {
         $error_controller = PHPBoostErrors::user_not_authorized();
         DispatchManager::redirect($error_controller);
     }
     if (AppContext::get_current_user()->is_readonly()) {
         $controller = PHPBoostErrors::user_in_read_only();
         DispatchManager::redirect($controller);
     }
 }
 private function check_authorizations()
 {
     if (!BugtrackerAuthorizationsService::check_authorizations()->moderation() && $this->current_user->get_id() != $this->bug->get_assigned_to_id()) {
         $error_controller = PHPBoostErrors::user_not_authorized();
         DispatchManager::redirect($error_controller);
     }
     if (AppContext::get_current_user()->is_readonly()) {
         $controller = PHPBoostErrors::user_in_read_only();
         DispatchManager::redirect($controller);
     }
 }