public function get_search_request($args)
 {
     $now = new Date();
     $authorized_categories = DownloadService::get_authorized_categories(Category::ROOT_CATEGORY);
     $weight = isset($args['weight']) && is_numeric($args['weight']) ? $args['weight'] : 1;
     return "SELECT " . $args['id_search'] . " AS id_search,\n\t\t\td.id AS id_content,\n\t\t\td.name AS title,\n\t\t\t( 2 * FT_SEARCH_RELEVANCE(d.name, '" . $args['search'] . "') + (FT_SEARCH_RELEVANCE(d.contents, '" . $args['search'] . "') +\n\t\t\tFT_SEARCH_RELEVANCE(d.short_contents, '" . $args['search'] . "')) / 2 ) / 3 * " . $weight . " AS relevance,\n\t\t\tCONCAT('" . PATH_TO_ROOT . "/download/index.php?url=/', id_category, '-', IF(id_category != 0, cat.rewrited_name, 'root'), '/', d.id, '-', d.rewrited_name) AS link\n\t\t\tFROM " . DownloadSetup::$download_table . " d\n\t\t\tLEFT JOIN " . DownloadSetup::$download_cats_table . " cat ON d.id_category = cat.id\n\t\t\tWHERE ( FT_SEARCH(d.name, '" . $args['search'] . "') OR FT_SEARCH(d.contents, '" . $args['search'] . "') OR FT_SEARCH_RELEVANCE(d.short_contents, '" . $args['search'] . "') )\n\t\t\tAND id_category IN (" . implode(", ", $authorized_categories) . ")\n\t\t\tAND (approbation_type = 1 OR (approbation_type = 2 AND start_date < '" . $now->get_timestamp() . "' AND (end_date > '" . $now->get_timestamp() . "' OR end_date = 0)))\n\t\t\tORDER BY relevance DESC\n\t\t\tLIMIT 100 OFFSET 0";
 }
 public function get_search_request($args)
 {
     $now = new Date();
     $authorized_categories = ArticlesService::get_authorized_categories(Category::ROOT_CATEGORY);
     $weight = isset($args['weight']) && is_numeric($args['weight']) ? $args['weight'] : 1;
     return "SELECT " . $args['id_search'] . " AS id_search,\n\t\t\tarticles.id AS id_content,\n\t\t\tarticles.title AS title,\n\t\t\t(2 * FT_SEARCH_RELEVANCE(articles.title, '" . $args['search'] . "') + (FT_SEARCH_RELEVANCE(articles.contents, '" . $args['search'] . "') +\n\t\t\tFT_SEARCH_RELEVANCE(articles.description, '" . $args['search'] . "')) / 2 ) / 3 * " . $weight . " AS relevance,\n\t\t\tCONCAT('" . PATH_TO_ROOT . "/articles/index.php?url=/', id_category, '-', IF(id_category != 0, cat.rewrited_name, 'root'), '/', articles.id, '-', articles.rewrited_title) AS link\n\t\t\tFROM " . ArticlesSetup::$articles_table . " articles\n\t\t\tLEFT JOIN " . ArticlesSetup::$articles_cats_table . " cat ON cat.id = articles.id_category\n\t\t\tWHERE ( FT_SEARCH(articles.title, '" . $args['search'] . "') OR FT_SEARCH(articles.contents, '" . $args['search'] . "') OR FT_SEARCH_RELEVANCE(articles.description, '" . $args['search'] . "') )\n\t\t\tAND id_category IN(" . implode(", ", $authorized_categories) . ")\n\t\t\tAND (published = 1 OR (published = 2 AND publishing_start_date < '" . $now->get_timestamp() . "' AND (publishing_end_date > '" . $now->get_timestamp() . "' OR publishing_end_date = 0)))\n\t\t\tORDER BY relevance DESC\n\t\t\tLIMIT 100 OFFSET 0";
 }
    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 build_view()
    {
        $now = new Date();
        $authorized_categories = NewsService::get_authorized_categories(Category::ROOT_CATEGORY);
        $news_config = NewsConfig::load();
        $condition = 'WHERE relation.id_keyword = :id_keyword
		AND id_category IN :authorized_categories
		AND (approbation_type = 1 OR (approbation_type = 2 AND start_date < :timestamp_now AND (end_date > :timestamp_now OR end_date = 0)))';
        $parameters = array('id_keyword' => $this->get_keyword()->get_id(), 'authorized_categories' => $authorized_categories, '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_KEYWORDS_RELATIONS . ' relation ON relation.module_id = \'news\' AND relation.id_in_module = news.id 
		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_PAGINATION' => $pagination->has_several_pages(), 'PAGINATION' => $pagination->display(), 'C_SEVERAL_COLUMNS' => $number_columns_display_news > 1, 'NUMBER_COLUMNS' => $number_columns_display_news, 'CATEGORY_NAME' => $this->get_keyword()->get_name()));
        while ($row = $result->fetch()) {
            $news = new News();
            $news->set_properties($row);
            $this->tpl->assign_block_vars('news', array_merge($news->get_array_tpl_vars(), array('L_COMMENTS' => CommentsService::get_number_and_lang_comments('news', $row['id']), 'NUMBER_COM' => !empty($row['number_comments']) ? $row['number_comments'] : 0)));
            $this->build_sources_view($news);
        }
        $result->dispose();
    }
    public function build_view(HTTPRequestCustom $request)
    {
        $now = new Date();
        $config = WebConfig::load();
        $authorized_categories = WebService::get_authorized_categories(Category::ROOT_CATEGORY);
        $mode = $request->get_getstring('sort', WebUrlBuilder::DEFAULT_SORT_MODE);
        $field = $request->get_getstring('field', WebUrlBuilder::DEFAULT_SORT_FIELD);
        $condition = 'WHERE relation.id_keyword = :id_keyword
		AND id_category IN :authorized_categories
		AND (approbation_type = 1 OR (approbation_type = 2 AND start_date < :timestamp_now AND (end_date > :timestamp_now OR end_date = 0)))';
        $parameters = array('id_keyword' => $this->get_keyword()->get_id(), 'authorized_categories' => $authorized_categories, 'timestamp_now' => $now->get_timestamp());
        $page = AppContext::get_request()->get_getint('page', 1);
        $pagination = $this->get_pagination($condition, $parameters, $field, $mode, $page);
        $sort_mode = $mode == 'asc' ? 'ASC' : 'DESC';
        switch ($field) {
            case 'name':
                $sort_field = WebLink::SORT_ALPHABETIC;
                break;
            case 'visits':
                $sort_field = WebLink::SORT_NUMBER_VISITS;
                break;
            case 'com':
                $sort_field = WebLink::SORT_NUMBER_COMMENTS;
                break;
            case 'note':
                $sort_field = WebLink::SORT_NOTATION;
                break;
            default:
                $sort_field = WebLink::SORT_DATE;
                break;
        }
        $result = PersistenceContext::get_querier()->select('SELECT web.*, member.*, com.number_comments, notes.average_notes, notes.number_notes, note.note
		FROM ' . WebSetup::$web_table . ' web
		LEFT JOIN ' . DB_TABLE_KEYWORDS_RELATIONS . ' relation ON relation.module_id = \'web\' AND relation.id_in_module = web.id 
		LEFT JOIN ' . DB_TABLE_MEMBER . ' member ON member.user_id = web.author_user_id
		LEFT JOIN ' . DB_TABLE_COMMENTS_TOPIC . ' com ON com.id_in_module = web.id AND com.module_id = \'web\'
		LEFT JOIN ' . DB_TABLE_AVERAGE_NOTES . ' notes ON notes.id_in_module = web.id AND notes.module_name = \'web\'
		LEFT JOIN ' . DB_TABLE_NOTE . ' note ON note.id_in_module = web.id AND note.module_name = \'web\' AND note.user_id = :user_id
		' . $condition . '
		ORDER BY web.privileged_partner DESC, ' . $sort_field . ' ' . $sort_mode . '
		LIMIT :number_items_per_page OFFSET :display_from', array_merge($parameters, array('user_id' => AppContext::get_current_user()->get_id(), 'number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from())));
        $this->tpl->put_all(array('C_WEBLINKS' => $result->get_rows_count() > 0, 'C_MORE_THAN_ONE_WEBLINK' => $result->get_rows_count() > 1, 'C_CATEGORY_DISPLAYED_SUMMARY' => $config->is_category_displayed_summary(), 'C_CATEGORY_DISPLAYED_TABLE' => $config->is_category_displayed_table(), 'C_COMMENTS_ENABLED' => $config->are_comments_enabled(), 'C_NOTATION_ENABLED' => $config->is_notation_enabled(), 'C_PAGINATION' => $pagination->has_several_pages(), 'PAGINATION' => $pagination->display(), 'TABLE_COLSPAN' => 3 + (int) $config->are_comments_enabled() + (int) $config->is_notation_enabled(), 'CATEGORY_NAME' => $this->get_keyword()->get_name()));
        while ($row = $result->fetch()) {
            $weblink = new WebLink();
            $weblink->set_properties($row);
            $keywords = $weblink->get_keywords();
            $has_keywords = count($keywords) > 0;
            $this->tpl->assign_block_vars('weblinks', array_merge($weblink->get_array_tpl_vars(), array('C_KEYWORDS' => $has_keywords)));
            if ($has_keywords) {
                $this->build_keywords_view($keywords);
            }
        }
        $result->dispose();
        $this->build_sorting_form($field, $mode);
    }
 private function get_view()
 {
     $this->check_authorizations();
     global $Bread_crumb, $LANG;
     require_once PATH_TO_ROOT . '/poll/poll_begin.php';
     $tpl = new FileTemplate('poll/poll.tpl');
     $now = new Date();
     $show_archives = PersistenceContext::get_querier()->count(PREFIX . "poll", 'WHERE archive = 1 AND visible = 1 AND start <= :timestamp AND (end >= :timestamp OR end = 0)', array('timestamp' => $now->get_timestamp()));
     $show_archives = !empty($show_archives) ? '<a href="poll' . url('.php?archives=1', '.php?archives=1') . '">' . $LANG['archives'] . '</a>' : '';
     $edit = '';
     if (AppContext::get_current_user()->check_level(User::ADMIN_LEVEL)) {
         $edit = '<a href="' . PATH_TO_ROOT . '/poll/admin_poll.php" title="' . LangLoader::get_message('edit', 'common') . '" class="fa fa-edit"></a>';
     }
     $tpl->put_all(array('C_POLL_MAIN' => true, 'EDIT' => $edit, 'U_ARCHIVE' => $show_archives, 'L_POLL' => $LANG['poll'], 'L_POLL_MAIN' => $LANG['poll_main']));
     $result = PersistenceContext::get_querier()->select("SELECT id, question \r\n\t\tFROM " . PREFIX . "poll \r\n\t\tWHERE archive = 0 AND visible = 1 AND start <= :timestamp AND (end >= :timestamp OR end = 0)\r\n\t\tORDER BY id DESC", array('timestamp' => $now->get_timestamp()));
     while ($row = $result->fetch()) {
         $tpl->assign_block_vars('list', array('U_POLL_ID' => url('.php?id=' . $row['id'], '-' . $row['id'] . '.php'), 'QUESTION' => stripslashes($row['question'])));
     }
     $result->dispose();
     return $tpl;
 }
    public function build_view(HTTPRequestCustom $request)
    {
        $now = new Date();
        $config = DownloadConfig::load();
        $authorized_categories = DownloadService::get_authorized_categories(Category::ROOT_CATEGORY);
        $mode = $request->get_getstring('sort', DownloadUrlBuilder::DEFAULT_SORT_MODE);
        $field = $request->get_getstring('field', DownloadUrlBuilder::DEFAULT_SORT_FIELD);
        $condition = 'WHERE id_category IN :authorized_categories
		' . (!DownloadAuthorizationsService::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('user_id' => AppContext::get_current_user()->get_id(), 'authorized_categories' => $authorized_categories, 'timestamp_now' => $now->get_timestamp());
        $page = AppContext::get_request()->get_getint('page', 1);
        $pagination = $this->get_pagination($condition, $parameters, $field, $mode, $page);
        $sort_mode = $mode == 'asc' ? 'ASC' : 'DESC';
        switch ($field) {
            case 'name':
                $sort_field = DownloadFile::SORT_ALPHABETIC;
                break;
            case 'author':
                $sort_field = DownloadFile::SORT_AUTHOR;
                break;
            default:
                $sort_field = DownloadFile::SORT_DATE;
                break;
        }
        $result = PersistenceContext::get_querier()->select('SELECT download.*, member.*, com.number_comments, notes.average_notes, notes.number_notes, note.note
		FROM ' . DownloadSetup::$download_table . ' download
		LEFT JOIN ' . DB_TABLE_MEMBER . ' member ON member.user_id = download.author_user_id
		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 = :user_id
		' . $condition . '
		ORDER BY ' . $sort_field . ' ' . $sort_mode . '
		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->tpl->put_all(array('C_FILES' => $result->get_rows_count() > 0, 'C_MORE_THAN_ONE_FILE' => $result->get_rows_count() > 1, 'C_PENDING' => true, 'C_CATEGORY_DISPLAYED_SUMMARY' => $config->is_category_displayed_summary(), 'C_CATEGORY_DISPLAYED_TABLE' => $config->is_category_displayed_table(), 'C_COMMENTS_ENABLED' => $config->are_comments_enabled(), 'C_NOTATION_ENABLED' => $config->is_notation_enabled(), 'C_AUTHOR_DISPLAYED' => $config->is_author_displayed(), 'C_PAGINATION' => $pagination->has_several_pages(), 'PAGINATION' => $pagination->display(), 'TABLE_COLSPAN' => 4 + (int) $config->are_comments_enabled() + (int) $config->is_notation_enabled()));
        while ($row = $result->fetch()) {
            $downloadfile = new DownloadFile();
            $downloadfile->set_properties($row);
            $keywords = $downloadfile->get_keywords();
            $has_keywords = count($keywords) > 0;
            $this->tpl->assign_block_vars('downloadfiles', array_merge($downloadfile->get_array_tpl_vars(), array('C_KEYWORDS' => $has_keywords)));
            if ($has_keywords) {
                $this->build_keywords_view($keywords);
            }
        }
        $result->dispose();
        $this->build_sorting_form($field, $mode);
    }
 static function save_alert(&$alert)
 {
     global $Sql, $Cache;
     if ($alert->get_id() > 0) {
         $creation_date = $alert->get_creation_date();
         $Sql->query_inject("UPDATE " . DB_TABLE_EVENTS . " SET entitled = '" . addslashes($alert->get_entitled()) . "', description = '" . addslashes($alert->get_properties()) . "', fixing_url = '" . addslashes($alert->get_fixing_url()) . "', current_status = '" . $alert->get_status() . "', creation_date = '" . $creation_date->get_timestamp() . "', id_in_module = '" . $alert->get_id_in_module() . "', identifier = '" . addslashes($alert->get_identifier()) . "', type = '" . addslashes($alert->get_type()) . "', priority = '" . $alert->get_priority() . "' WHERE id = '" . $alert->get_id() . "'", __LINE__, __FILE__);
         if ($alert->get_must_regenerate_cache()) {
             $Cache->generate_file('member');
             $alert->set_must_regenerate_cache(false);
         }
     } else {
         $creation_date = new Date();
         $Sql->query_inject("INSERT INTO " . DB_TABLE_EVENTS . " (entitled, description, fixing_url, current_status, creation_date, id_in_module, identifier, type, priority) VALUES ('" . addslashes($alert->get_entitled()) . "', '" . addslashes($alert->get_properties()) . "', '" . addslashes($alert->get_fixing_url()) . "', '" . $alert->get_status() . "', '" . $creation_date->get_timestamp() . "', '" . $alert->get_id_in_module() . "', '" . addslashes($alert->get_identifier()) . "', '" . addslashes($alert->get_type()) . "', '" . $alert->get_priority() . "')", __LINE__, __FILE__);
         $alert->set_id($Sql->insert_id("SELECT MAX(id) FROM " . DB_TABLE_EVENTS));
         $Cache->generate_file('member');
     }
 }
    /**
     * {@inheritdoc}
     */
    public function synchronize()
    {
        $this->downloadfiles = array();
        $now = new Date();
        $config = DownloadConfig::load();
        $result = PersistenceContext::get_querier()->select('
			SELECT download.*, notes.average_notes, notes.number_notes
			FROM ' . DownloadSetup::$download_table . ' download
			LEFT JOIN ' . DB_TABLE_AVERAGE_NOTES . ' notes ON notes.id_in_module = download.id AND notes.module_name = \'download\'
			WHERE (approbation_type = 1 OR (approbation_type = 2 AND start_date < :timestamp_now AND (end_date > :timestamp_now OR end_date = 0)))
			ORDER BY ' . $config->get_sort_type() . ' DESC
			LIMIT :files_number_in_menu OFFSET 0', array('timestamp_now' => $now->get_timestamp(), 'files_number_in_menu' => (int) $config->get_files_number_in_menu()));
        while ($row = $result->fetch()) {
            $this->downloadfiles[$row['id']] = $row;
        }
        $result->dispose();
    }
示例#10
0
    /**
     * {@inheritdoc}
     */
    public function synchronize()
    {
        $this->partners_weblinks = array();
        $now = new Date();
        $config = WebConfig::load();
        $result = PersistenceContext::get_querier()->select('
			SELECT web.id, web.name, web.partner_picture
			FROM ' . WebSetup::$web_table . ' web
			LEFT JOIN ' . DB_TABLE_COMMENTS_TOPIC . ' com ON com.id_in_module = web.id AND com.module_id = \'web\'
			LEFT JOIN ' . DB_TABLE_AVERAGE_NOTES . ' notes ON notes.id_in_module = web.id AND notes.module_name = \'web\'
			WHERE web.approbation_type = 1 OR (web.approbation_type = 2 AND (web.start_date > :timestamp_now OR (end_date != 0 AND end_date < :timestamp_now))) AND partner = 1
			ORDER BY web.privileged_partner DESC, ' . $config->get_sort_type() . ' ' . $config->get_sort_mode() . '
			LIMIT :partners_number_in_menu OFFSET 0', array('timestamp_now' => $now->get_timestamp(), 'partners_number_in_menu' => (int) $config->get_partners_number_in_menu()));
        while ($row = $result->fetch()) {
            $this->partners_weblinks[$row['id']] = $row;
        }
        $result->dispose();
    }
    public function get_feed_data_struct($idcat = 0, $name = '')
    {
        if (ArticlesService::get_categories_manager()->get_categories_cache()->category_exists($idcat)) {
            $querier = PersistenceContext::get_querier();
            $category = ArticlesService::get_categories_manager()->get_categories_cache()->get_category($idcat);
            $site_name = GeneralConfig::load()->get_site_name();
            $site_name = $idcat != Category::ROOT_CATEGORY ? $site_name . ' : ' . $category->get_name() : $site_name;
            $feed_module_name = LangLoader::get_message('articles.feed_name', 'common', 'articles');
            $data = new FeedData();
            $data->set_title($feed_module_name . ' - ' . $site_name);
            $data->set_date(new Date());
            $data->set_link(SyndicationUrlBuilder::rss('articles', $idcat));
            $data->set_host(HOST);
            $data->set_desc($feed_module_name . ' - ' . $site_name);
            $data->set_lang(LangLoader::get_message('xml_lang', 'main'));
            $data->set_auth_bit(Category::READ_AUTHORIZATIONS);
            $categories = ArticlesService::get_categories_manager()->get_childrens($idcat, new SearchCategoryChildrensOptions(), true);
            $ids_categories = array_keys($categories);
            $now = new Date();
            $results = $querier->select('SELECT articles.id, articles.id_category, articles.title, articles.rewrited_title, articles.picture_url, 
			articles.contents, articles.description, articles.date_created, cat.rewrited_name AS rewrited_name_cat
			FROM ' . ArticlesSetup::$articles_table . ' articles
			LEFT JOIN ' . ArticlesSetup::$articles_cats_table . ' cat ON cat.id = articles.id_category
			WHERE articles.id_category IN :cats_ids
			AND (published = 1 OR (published = 2 AND publishing_start_date < :timestamp_now AND (publishing_end_date > :timestamp_now OR publishing_end_date = 0)))
			ORDER BY articles.date_created DESC', array('cats_ids' => $ids_categories, 'timestamp_now' => $now->get_timestamp()));
            foreach ($results as $row) {
                $row['rewrited_name_cat'] = !empty($row['id_category']) ? $row['rewrited_name_cat'] : 'root';
                $link = ArticlesUrlBuilder::display_article($row['id_category'], $row['rewrited_name_cat'], $row['id'], $row['rewrited_title']);
                $item = new FeedItem();
                $item->set_title($row['title']);
                $item->set_link($link);
                $item->set_guid($link);
                $item->set_desc(FormatingHelper::second_parse($row['contents']));
                $item->set_date(new Date($row['date_created'], Timezone::SERVER_TIMEZONE));
                $item->set_image_url($row['picture_url']);
                $item->set_auth(ArticlesService::get_categories_manager()->get_heritated_authorizations($row['id_category'], Category::READ_AUTHORIZATIONS, Authorizations::AUTH_PARENT_PRIORITY));
                $data->add_item($item);
            }
            $results->dispose();
            return $data;
        }
    }
 public function execute_add_comment_event()
 {
     //Load module lang
     $lang = LangLoader::get('common', 'bugtracker');
     //Load module configuration
     $config = BugtrackerConfig::load();
     //Get the content of the comment
     $comment = stripslashes(FormatingHelper::strparse(AppContext::get_request()->get_poststring('comments_message', '')));
     //Retrieve the id of the bug
     $bug_id = $this->comments_topic->get_id_in_module();
     $now = new Date();
     //New line in the bug history
     BugtrackerService::add_history(array('bug_id' => $bug_id, 'updater_id' => AppContext::get_current_user()->get_id(), 'update_date' => $now->get_timestamp(), 'change_comment' => $lang['notice.new_comment']));
     //Send a PM to the list of members who updated the bug if the send of PM is enabled
     if ($config->are_pm_enabled() && $config->are_pm_comment_enabled()) {
         BugtrackerPMService::send_PM_to_updaters('comment', $bug_id, $comment);
     }
     return true;
 }
示例#13
0
     if ($end_timestamp > time() && $end_timestamp > $start_timestamp && $start_timestamp != 0) {
         $visible = 2;
     } elseif ($start_timestamp != 0) {
         //Date inférieur à celle courante => inutile.
         $end_timestamp = 0;
     }
 } elseif ($get_visible == 1) {
     $start_timestamp = 0;
     $end_timestamp = 0;
 } else {
     $visible = 0;
     $start_timestamp = 0;
     $end_timestamp = 0;
 }
 $date = new Date($current_date);
 $timestamp = $date->get_timestamp();
 if ($timestamp > 0) {
     //Ajout des heures et minutes
     $timestamp += $hour * 3600 + $min * 60;
 } else {
     $timestamp = time();
 }
 $answers = '';
 $votes = '';
 for ($i = 0; $i < 20; $i++) {
     if ($request->has_postparameter('a' . $i)) {
         if (!empty(retrieve(POST, 'a' . $i, ''))) {
             $answers .= str_replace('|', '', retrieve(POST, 'a' . $i, '')) . '|';
             $votes .= str_replace('|', '', retrieve(POST, 'v' . $i, 0)) . '|';
         }
     }
示例#14
0
             //Image svg
             case 'svg':
                 $bbcode = '[img]/upload/' . $row['path'] . '[/img]';
                 $link = 'javascript:popup_upload(\'' . Url::to_rel('/upload/' . $row['path']) . '\', 0, 0, \'no\')';
                 break;
                 //Sons
             //Sons
             case 'mp3':
                 $bbcode = '[sound]/upload/' . $row['path'] . '[/sound]';
                 $link = 'javascript:popup_upload(\'' . Url::to_rel('/upload/' . $row['path']) . '\', 220, 10, \'no\')';
                 break;
             default:
                 $bbcode = '[url=/upload/' . $row['path'] . ']' . $row['name'] . '[/url]';
                 $link = PATH_TO_ROOT . '/upload/' . $row['path'];
         }
         $template->assign_block_vars('files', array('C_RECENT_FILE' => $row['timestamp'] > $now->get_timestamp() - 15 * 60, 'ID' => $row['id'], 'IMG' => $get_img_mimetype['img'], 'URL' => $link, 'NAME' => $name_cut, 'RENAME_FILE' => '<span id="fihref' . $row['id'] . '"><a href="javascript:display_rename_file(\'' . $row['id'] . '\', \'' . addslashes($row['name']) . '\', \'' . addslashes($name_cut) . '\');" title="' . LangLoader::get_message('edit', 'common') . '" class="fa fa-edit"></a></span>', 'FILETYPE' => $get_img_mimetype['filetype'] . $size_img, 'BBCODE' => '<input readonly="readonly" type="text" onclick="select_div(\'text_' . $row['id'] . '\');" id="text_' . $row['id'] . '" style="margin-top:2px;cursor:pointer;" value="' . $bbcode . '">', 'SIZE' => $row['size'] > 1024 ? NumberHelper::round($row['size'] / 1024, 2) . ' ' . LangLoader::get_message('unit.megabytes', 'common') : NumberHelper::round($row['size'], 0) . ' ' . LangLoader::get_message('unit.kilobytes', 'common'), 'LIGHTBOX' => !empty($size_img) ? ' data-lightbox="1" data-rel="lightcase:collection"' : '', 'U_MOVE' => '.php?movefi=' . $row['id'] . '&amp;f=' . $folder . '&amp;fm=' . $row['user_id']));
         $total_folder_size += $row['size'];
         $total_files++;
     }
     $result->dispose();
 }
 $total_size = 0;
 try {
     $total_size = PersistenceContext::get_querier()->get_column_value(DB_TABLE_UPLOAD, 'SUM(size)', '');
 } catch (RowNotFoundException $e) {
 }
 $template->put_all(array('TOTAL_SIZE' => $total_size > 1024 ? NumberHelper::round($total_size / 1024, 2) . ' ' . LangLoader::get_message('unit.megabytes', 'common') : NumberHelper::round($total_size, 0) . ' ' . LangLoader::get_message('unit.kilobytes', 'common'), 'TOTAL_FOLDER_SIZE' => $total_folder_size > 1024 ? NumberHelper::round($total_folder_size / 1024, 2) . ' ' . LangLoader::get_message('unit.megabytes', 'common') : NumberHelper::round($total_folder_size, 0) . ' ' . LangLoader::get_message('unit.kilobytes', 'common'), 'TOTAL_FOLDERS' => $total_directories, 'TOTAL_FILES' => $total_files));
 if ($total_directories == 0 && $total_files == 0 && (!empty($folder) || !empty($show_member))) {
     $template->put_all(array('C_EMPTY_FOLDER' => true, 'L_EMPTY_FOLDER' => LangLoader::get_message('no_item_now', 'common')));
 }
 $template->display();
 private function save()
 {
     $now = new Date();
     $pm_recipients_list = array();
     $send_pm = true;
     $versions = array_reverse($this->config->get_versions_fix(), true);
     $status = $this->form->get_value('status')->get_raw_value();
     if (count($versions)) {
         if (!$this->form->field_is_disabled('fixed_in')) {
             $fixed_in = $this->form->get_value('fixed_in')->get_raw_value() ? $this->form->get_value('fixed_in')->get_raw_value() : 0;
             if ($fixed_in != $this->bug->get_fixed_in()) {
                 //Bug history update
                 BugtrackerService::add_history(array('bug_id' => $this->bug->get_id(), 'updater_id' => $this->current_user->get_id(), 'update_date' => $now->get_timestamp(), 'updated_field' => 'fixed_in', 'old_value' => $this->bug->get_fixed_in(), 'new_value' => $fixed_in));
                 $this->bug->set_fixed_in($fixed_in);
             }
         } else {
             if (in_array($status, array(Bug::NEW_BUG, Bug::REJECTED))) {
                 $this->bug->set_fixed_in(0);
             }
         }
     }
     if (!$this->form->field_is_disabled('assigned_to')) {
         $assigned_to = $this->form->get_value('assigned_to');
         $assigned_to_id = UserService::user_exists("WHERE display_name = :display_name", array('display_name' => $assigned_to));
         if ($this->bug->get_assigned_to_id()) {
             $old_user_assigned_id = UserService::user_exists("WHERE user_id = :user_id", array('user_id' => $this->bug->get_assigned_to_id()));
             $old_user_assigned = !empty($old_user_assigned_id) ? UserService::get_user($old_user_assigned_id) : 0;
         } else {
             $old_user_assigned = 0;
         }
         $new_user_assigned = !empty($assigned_to) && !empty($assigned_to_id) ? UserService::get_user($assigned_to_id) : 0;
         $new_assigned_to_id = !empty($new_user_assigned) ? $new_user_assigned->get_id() : 0;
         if ($new_assigned_to_id != $this->bug->get_assigned_to_id()) {
             //Bug history update
             BugtrackerService::add_history(array('bug_id' => $this->bug->get_id(), 'updater_id' => $this->current_user->get_id(), 'update_date' => $now->get_timestamp(), 'updated_field' => 'assigned_to_id', 'old_value' => $old_user_assigned ? $old_user_assigned->get_display_name() : $this->lang['notice.no_one'], 'new_value' => $new_user_assigned ? $new_user_assigned->get_display_name() : $this->lang['notice.no_one']));
             //Bug update
             $this->bug->set_assigned_to_id($new_assigned_to_id);
             //The PM will only be sent to the assigned user
             if ($new_assigned_to_id != $this->current_user->get_id()) {
                 $pm_recipients_list[] = $new_assigned_to_id;
             } else {
                 $send_pm = false;
             }
         }
     }
     if ($status != $this->bug->get_status()) {
         //Bug history update
         BugtrackerService::add_history(array('bug_id' => $this->bug->get_id(), 'updater_id' => $this->current_user->get_id(), 'update_date' => $now->get_timestamp(), 'updated_field' => 'status', 'old_value' => $this->bug->get_status(), 'new_value' => $status));
         //Bug update
         $this->bug->set_status($status);
         if ($this->bug->is_fixed() || $this->bug->is_rejected()) {
             $this->bug->set_fix_date($now);
         } else {
             $this->bug->set_fix_date(0);
         }
     }
     BugtrackerService::update($this->bug);
     Feed::clear_cache('bugtracker');
     switch ($status) {
         case Bug::IN_PROGRESS:
             $is_pm_enabled = $this->config->are_pm_in_progress_enabled();
             break;
         case Bug::PENDING:
             $is_pm_enabled = $this->config->are_pm_pending_enabled();
             break;
         case Bug::ASSIGNED:
             $is_pm_enabled = $this->config->are_pm_assign_enabled();
             break;
         case Bug::FIXED:
             $is_pm_enabled = $this->config->are_pm_fix_enabled();
             break;
         case Bug::REOPEN:
             $is_pm_enabled = $this->config->are_pm_reopen_enabled();
             break;
         case Bug::REJECTED:
             $is_pm_enabled = $this->config->are_pm_reject_enabled();
             break;
         default:
             $is_pm_enabled = false;
             break;
     }
     //Add comment if needed
     $comment = $this->form->get_value('comments_message', '');
     if (!empty($comment)) {
         $comments_topic = new BugtrackerCommentsTopic();
         $comments_topic->set_id_in_module($this->bug->get_id());
         $comments_topic->set_url(BugtrackerUrlBuilder::detail($this->bug->get_id() . '-' . $this->bug->get_rewrited_title()));
         CommentsManager::add_comment($comments_topic->get_module_id(), $comments_topic->get_id_in_module(), $comments_topic->get_topic_identifier(), $comments_topic->get_path(), $comment);
         //New line in the bug history
         BugtrackerService::add_history(array('bug_id' => $this->bug->get_id(), 'updater_id' => $this->current_user->get_id(), 'update_date' => $now->get_timestamp(), 'change_comment' => $this->lang['notice.new_comment']));
     }
     //Send PM with comment to updaters if the option is enabled
     if (!$this->bug->is_new() && $this->config->are_pm_enabled() && $is_pm_enabled && $send_pm) {
         BugtrackerPMService::send_PM_to_updaters($status, $this->bug->get_id(), $comment, $pm_recipients_list);
     }
     if (in_array($status, array(Bug::NEW_BUG, Bug::REOPEN, Bug::REJECTED, Bug::FIXED)) && $this->config->are_admin_alerts_enabled() && in_array($this->bug->get_severity(), $this->config->get_admin_alerts_levels())) {
         $alerts = AdministratorAlertService::find_by_criteria($this->bug->get_id(), 'bugtracker');
         if (!empty($alerts)) {
             $alert = $alerts[0];
             if ($this->bug->is_new() || $this->bug->is_reopen()) {
                 $alert->set_status(AdministratorAlert::ADMIN_ALERT_STATUS_UNREAD);
                 AdministratorAlertService::save_alert($alert);
             } else {
                 if ($this->config->is_admin_alerts_fix_action_fix()) {
                     $alert->set_status(AdministratorAlert::ADMIN_ALERT_STATUS_PROCESSED);
                     AdministratorAlertService::save_alert($alert);
                 } else {
                     AdministratorAlertService::delete_alert($alert);
                 }
             }
         }
     }
     BugtrackerStatsCache::invalidate();
 }
    private function build_navigation_links(News $news)
    {
        $now = new Date();
        $timestamp_news = $news->get_creation_date()->get_timestamp();
        $result = PersistenceContext::get_querier()->select('
		(SELECT id, name, id_category, rewrited_name, \'PREVIOUS\' as type
		FROM ' . NewsSetup::$news_table . '
		WHERE (approbation_type = 1 OR (approbation_type = 2 AND start_date < :timestamp_now AND (end_date > :timestamp_now OR end_date = 0))) AND creation_date < :timestamp_news AND id_category IN :authorized_categories ORDER BY creation_date DESC LIMIT 1 OFFSET 0)
		UNION
		(SELECT id, name, id_category, rewrited_name, \'NEXT\' as type
		FROM ' . NewsSetup::$news_table . '
		WHERE (approbation_type = 1 OR (approbation_type = 2 AND start_date < :timestamp_now AND (end_date > :timestamp_now OR end_date = 0))) AND creation_date > :timestamp_news AND id_category IN :authorized_categories ORDER BY creation_date ASC LIMIT 1 OFFSET 0)
		', array('timestamp_now' => $now->get_timestamp(), 'timestamp_news' => $timestamp_news, 'authorized_categories' => array($news->get_id_cat())));
        while ($row = $result->fetch()) {
            $this->tpl->put_all(array('C_NEWS_NAVIGATION_LINKS' => true, 'C_' . $row['type'] . '_NEWS' => true, $row['type'] . '_NEWS' => $row['name'], 'U_' . $row['type'] . '_NEWS' => NewsUrlBuilder::display_news($row['id_category'], NewsService::get_categories_manager()->get_categories_cache()->get_category($row['id_category'])->get_rewrited_name(), $row['id'], $row['rewrited_name'])->rel()));
        }
        $result->dispose();
    }
示例#17
0
 /**
  * @desc Formats the date to a particular format.
  * @param int $format One of the following enumeration:
  * <ul>
  * 	<li>Date::FORMAT_DAY_MONTH for a tiny formatting (only month and day)</li>
  * 	<li>Date::FORMAT_DAY_MONTH_YEAR for a short formatting (month, day, year)</li>
  * 	<li>Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE for a longer displaying (year, month, day, hour and minutes)</li>
  *  <li>Date::FORMAT_TIMESTAMP for a timestamp</li>
  * 	<li>Date::FORMAT_RFC822 to format according to what the RFC822 announces</li>
  * 	<li>Date::FORMAT_ISO8601 to format according to what the ISO8601 announces</li>
  * 	<li>Date::FORMAT_DAY_MONTH_YEAR_LONG</li>
  * 	<li>Date::FORMAT_DAY_MONTH_YEAR_TEXT</li>
  * 	<li>Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE_TEXT</li>
  * 	<li>Date::FORMAT_RELATIVE</li>
  * 	<li>Date::FORMAT_ISO_DAY_MONTH_YEAR</li>
  * </ul>
  * @param int $referencial_timezone One of the following enumeration:
  * <ul>
  * 	<li>Timezone::SERVER_TIMEZONE</li>
  * 	<li>Timezone::SITE_TIMEZONE</li>
  * 	<li>Timezone::USER_TIMEZONE</li>
  * </ul>
  * @return string The formatted date
  */
 public function format($format = self::FORMAT_DAY_MONTH, $referencial_timezone = Timezone::USER_TIMEZONE)
 {
     $this->compute_server_user_difference($referencial_timezone);
     if (is_string($format)) {
         return $this->date_time->format($format);
     }
     switch ($format) {
         case self::FORMAT_DAY_MONTH:
             return $this->date_time->format(LangLoader::get_message('date_format_day_month', 'date-common'));
             break;
         case self::FORMAT_DAY_MONTH_YEAR:
             return $this->date_time->format(LangLoader::get_message('date_format_day_month_year', 'date-common'));
             break;
         case self::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE:
             return $this->date_time->format(LangLoader::get_message('date_format_day_month_year_hour_minute', 'date-common'));
             break;
         case self::FORMAT_TIMESTAMP:
             return $this->date_time->getTimestamp();
             break;
         case self::FORMAT_RFC2822:
             return $this->date_time->format('r');
             break;
         case self::FORMAT_ISO8601:
             return $this->date_time->format('c');
             break;
         case self::FORMAT_DAY_MONTH_YEAR_LONG:
             return self::transform_date($this->date_time->format(LangLoader::get_message('date_format_day_month_year_long', 'date-common')));
             break;
         case self::FORMAT_DAY_MONTH_YEAR_TEXT:
             return self::transform_date($this->date_time->format(LangLoader::get_message('date_format_day_month_year_text', 'date-common')));
             break;
         case self::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE_TEXT:
             return self::transform_date($this->date_time->format(LangLoader::get_message('date_format_day_month_year_hour_minute_text', 'date-common')));
             break;
         case self::FORMAT_RELATIVE:
             $now = new Date(Date::DATE_NOW, $referencial_timezone);
             if ($now->get_timestamp() > $this->get_timestamp()) {
                 $time_diff = $now->get_timestamp() - $this->get_timestamp();
             } else {
                 $time_diff = $this->get_timestamp() - $now->get_timestamp();
             }
             $secondes = $time_diff;
             $minutes = round($time_diff / 60);
             $hours = round($time_diff / 3600);
             $days = round($time_diff / 86400);
             $weeks = round($time_diff / 604800);
             $months = round($time_diff / 2419200);
             $years = round($time_diff / 29030400);
             if ($secondes == 1) {
                 return LangLoader::get_message('instantly', 'date-common');
             } elseif ($secondes < 60) {
                 return $secondes . ' ' . LangLoader::get_message('seconds', 'date-common');
             } elseif ($minutes < 60) {
                 return $minutes . ' ' . ($minutes > 1 ? LangLoader::get_message('minutes', 'date-common') : LangLoader::get_message('minute', 'date-common'));
             } elseif ($hours < 24) {
                 return $hours . ' ' . ($hours > 1 ? LangLoader::get_message('hours', 'date-common') : LangLoader::get_message('hour', 'date-common'));
             } elseif ($days < 7) {
                 return $days . ' ' . ($days > 1 ? LangLoader::get_message('days', 'date-common') : LangLoader::get_message('day', 'date-common'));
             } elseif ($weeks < 4) {
                 return $weeks . ' ' . ($weeks > 1 ? LangLoader::get_message('weeks', 'date-common') : LangLoader::get_message('week', 'date-common'));
             } elseif ($months < 12) {
                 return $months . ' ' . LangLoader::get_message('months', 'date-common');
             } else {
                 return $years . ' ' . ($years > 1 ? LangLoader::get_message('years', 'date-common') : LangLoader::get_message('year', 'date-common'));
             }
             break;
         case self::FORMAT_ISO_DAY_MONTH_YEAR:
             return $this->date_time->format('Y-m-d');
             break;
         default:
             return '';
     }
 }
    private function build_view(HTTPRequestCustom $request)
    {
        $now = new Date();
        $authorized_categories = DownloadService::get_authorized_categories($this->get_category()->get_id());
        $mode = $request->get_getstring('sort', DownloadUrlBuilder::DEFAULT_SORT_MODE);
        $field = $request->get_getstring('field', DownloadUrlBuilder::DEFAULT_SORT_FIELD);
        $page = AppContext::get_request()->get_getint('page', 1);
        $subcategories_page = AppContext::get_request()->get_getint('subcategories_page', 1);
        $subcategories_number = count(DownloadService::get_categories_manager()->get_categories_cache()->get_childrens($this->get_category()->get_id()));
        $subcategories_pagination = $this->get_subcategories_pagination($subcategories_number, $this->config->get_categories_number_per_page(), $field, $mode, $page, $subcategories_page);
        //Children categories
        $result = PersistenceContext::get_querier()->select('SELECT @id_cat:= download_cats.id, download_cats.*,
		(SELECT COUNT(*) FROM ' . DownloadSetup::$download_table . '
			WHERE id_category IN (
				@id_cat,
				(SELECT GROUP_CONCAT(id SEPARATOR \',\') FROM ' . DownloadSetup::$download_cats_table . ' WHERE id_parent = @id_cat), 
				(SELECT GROUP_CONCAT(childs.id SEPARATOR \',\') FROM ' . DownloadSetup::$download_cats_table . ' parents
				INNER JOIN ' . DownloadSetup::$download_cats_table . ' childs ON parents.id = childs.id_parent
				WHERE parents.id_parent = @id_cat)
			)
			AND (approbation_type = 1 OR (approbation_type = 2 AND start_date < :timestamp_now AND (end_date > :timestamp_now OR end_date = 0)))
		) AS downloadfiles_number
		FROM ' . DownloadSetup::$download_cats_table . ' download_cats
		WHERE id_parent = :id_category
		AND id IN :authorized_categories
		ORDER BY id_parent, c_order
		LIMIT :number_items_per_page OFFSET :display_from', array('timestamp_now' => $now->get_timestamp(), 'id_category' => $this->category->get_id(), 'authorized_categories' => $authorized_categories, 'number_items_per_page' => $subcategories_pagination->get_number_items_per_page(), 'display_from' => $subcategories_pagination->get_display_from()));
        $nbr_cat_displayed = 0;
        while ($row = $result->fetch()) {
            $category_image = new Url($row['image']);
            $this->tpl->assign_block_vars('sub_categories_list', array('C_CATEGORY_IMAGE' => !empty($row['image']), 'C_MORE_THAN_ONE_DOWNLOADFILE' => $row['downloadfiles_number'] > 1, 'CATEGORY_NAME' => $row['name'], 'CATEGORY_IMAGE' => $category_image->rel(), 'DOWNLOADFILES_NUMBER' => $row['downloadfiles_number'], 'U_CATEGORY' => DownloadUrlBuilder::display_category($row['id'], $row['rewrited_name'])->rel()));
            $nbr_cat_displayed++;
        }
        $result->dispose();
        $nbr_column_cats = $nbr_cat_displayed > $this->config->get_columns_number_per_line() ? $this->config->get_columns_number_per_line() : $nbr_cat_displayed;
        $nbr_column_cats = !empty($nbr_column_cats) ? $nbr_column_cats : 1;
        $cats_columns_width = floor(100 / $nbr_column_cats);
        $condition = 'WHERE id_category = :id_category
		AND (approbation_type = 1 OR (approbation_type = 2 AND start_date < :timestamp_now AND (end_date > :timestamp_now OR end_date = 0)))';
        $parameters = array('id_category' => $this->get_category()->get_id(), 'timestamp_now' => $now->get_timestamp());
        $pagination = $this->get_pagination($condition, $parameters, $field, $mode, $page, $subcategories_page);
        $sort_mode = $mode == 'asc' ? 'ASC' : 'DESC';
        switch ($field) {
            case 'name':
                $sort_field = DownloadFile::SORT_ALPHABETIC;
                break;
            case 'download':
                $sort_field = DownloadFile::SORT_NUMBER_DOWNLOADS;
                break;
            case 'com':
                $sort_field = DownloadFile::SORT_NUMBER_COMMENTS;
                break;
            case 'note':
                $sort_field = DownloadFile::SORT_NOTATION;
                break;
            case 'author':
                $sort_field = DownloadFile::SORT_AUTHOR;
                break;
            case 'date':
                $sort_field = DownloadFile::SORT_DATE;
                break;
            default:
                $sort_field = DownloadFile::SORT_UPDATED_DATE;
                break;
        }
        $result = PersistenceContext::get_querier()->select('SELECT download.*, member.*, com.number_comments, notes.average_notes, notes.number_notes, note.note
		FROM ' . DownloadSetup::$download_table . ' download
		LEFT JOIN ' . DB_TABLE_MEMBER . ' member ON member.user_id = download.author_user_id
		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 = :user_id
		' . $condition . '
		ORDER BY ' . $sort_field . ' ' . $sort_mode . '
		LIMIT :number_items_per_page OFFSET :display_from', array_merge($parameters, array('user_id' => AppContext::get_current_user()->get_id(), 'number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from())));
        $category_description = FormatingHelper::second_parse($this->get_category()->get_description());
        $this->tpl->put_all(array('C_FILES' => $result->get_rows_count() > 0, 'C_MORE_THAN_ONE_FILE' => $result->get_rows_count() > 1, 'C_CATEGORY_DISPLAYED_SUMMARY' => $this->config->is_category_displayed_summary(), 'C_CATEGORY_DISPLAYED_TABLE' => $this->config->is_category_displayed_table(), 'C_CATEGORY_DESCRIPTION' => !empty($category_description), 'C_AUTHOR_DISPLAYED' => $this->config->is_author_displayed(), 'C_COMMENTS_ENABLED' => $this->config->are_comments_enabled(), 'C_NOTATION_ENABLED' => $this->config->is_notation_enabled(), 'C_MODERATION' => DownloadAuthorizationsService::check_authorizations($this->get_category()->get_id())->moderation(), 'C_PAGINATION' => $pagination->has_several_pages(), 'C_CATEGORY' => true, 'C_ROOT_CATEGORY' => $this->get_category()->get_id() == Category::ROOT_CATEGORY, 'C_HIDE_NO_ITEM_MESSAGE' => $this->get_category()->get_id() == Category::ROOT_CATEGORY && ($nbr_cat_displayed != 0 || !empty($category_description)), 'C_SUB_CATEGORIES' => $nbr_cat_displayed > 0, 'C_SUBCATEGORIES_PAGINATION' => $subcategories_pagination->has_several_pages(), 'SUBCATEGORIES_PAGINATION' => $subcategories_pagination->display(), 'CATS_COLUMNS_WIDTH' => $cats_columns_width, 'PAGINATION' => $pagination->display(), 'TABLE_COLSPAN' => 4 + (int) $this->config->are_comments_enabled() + (int) $this->config->is_notation_enabled(), 'ID_CAT' => $this->get_category()->get_id(), 'CATEGORY_NAME' => $this->get_category()->get_name(), 'CATEGORY_IMAGE' => $this->get_category()->get_image()->rel(), 'CATEGORY_DESCRIPTION' => $category_description, 'U_EDIT_CATEGORY' => $this->get_category()->get_id() == Category::ROOT_CATEGORY ? DownloadUrlBuilder::configuration()->rel() : DownloadUrlBuilder::edit_category($this->get_category()->get_id())->rel()));
        while ($row = $result->fetch()) {
            $downloadfile = new DownloadFile();
            $downloadfile->set_properties($row);
            $keywords = $downloadfile->get_keywords();
            $has_keywords = count($keywords) > 0;
            $this->tpl->assign_block_vars('downloadfiles', array_merge($downloadfile->get_array_tpl_vars(), array('C_KEYWORDS' => $has_keywords)));
            if ($has_keywords) {
                $this->build_keywords_view($keywords);
            }
        }
        $result->dispose();
        $this->build_sorting_form($field, $mode);
    }
    private function build_view($request)
    {
        $now = new Date();
        $authorized_categories = ArticlesService::get_authorized_categories(Category::ROOT_CATEGORY);
        $config = ArticlesConfig::load();
        $mode = $request->get_getstring('sort', 'desc');
        $field = $request->get_getstring('field', 'date');
        $sort_mode = $mode == 'asc' ? 'ASC' : 'DESC';
        switch ($field) {
            case 'title':
                $sort_field = 'title';
                break;
            case 'view':
                $sort_field = 'number_view';
                break;
            case 'com':
                $sort_field = 'number_comments';
                break;
            case 'note':
                $sort_field = 'average_notes';
                break;
            case 'author':
                $sort_field = 'display_name';
                break;
            default:
                $sort_field = 'date_created';
                break;
        }
        $condition = 'WHERE id_category IN :authorized_categories
		' . (!ArticlesAuthorizationsService::check_authorizations()->moderation() ? ' AND author_user_id = :user_id' : '') . '
		AND (published = 0 OR (published = 2 AND (publishing_start_date > :timestamp_now OR (publishing_end_date != 0 AND publishing_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, $field, $mode, $page);
        $result = PersistenceContext::get_querier()->select('SELECT articles.*, member.*, com.number_comments, notes.number_notes, notes.average_notes, note.note 
		FROM ' . ArticlesSetup::$articles_table . ' articles
		LEFT JOIN ' . DB_TABLE_MEMBER . ' member ON member.user_id = articles.author_user_id
		LEFT JOIN ' . DB_TABLE_COMMENTS_TOPIC . ' com ON com.id_in_module = articles.id AND com.module_id = "articles"
		LEFT JOIN ' . DB_TABLE_AVERAGE_NOTES . ' notes ON notes.id_in_module = articles.id AND notes.module_name = "articles"
		LEFT JOIN ' . DB_TABLE_NOTE . ' note ON note.id_in_module = articles.id AND note.module_name = "articles" AND note.user_id = :user_id
		' . $condition . '
		ORDER BY ' . $sort_field . ' ' . $sort_mode . '
		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())));
        $nbr_articles_pending = $result->get_rows_count();
        $this->build_form($field, $mode);
        $this->view->put_all(array('C_PENDING' => true, 'C_MOSAIC' => $config->get_display_type() == ArticlesConfig::DISPLAY_MOSAIC, 'C_NO_ARTICLE_AVAILABLE' => $nbr_articles_pending == 0));
        if ($nbr_articles_pending > 0) {
            $this->view->put_all(array('C_ARTICLES_FILTERS' => true, 'C_COMMENTS_ENABLED' => $config->are_comments_enabled(), 'C_NOTATION_ENABLED' => $config->is_notation_enabled(), 'C_PAGINATION' => $pagination->has_several_pages(), 'PAGINATION' => $pagination->display()));
            while ($row = $result->fetch()) {
                $article = new Article();
                $article->set_properties($row);
                $this->build_keywords_view($article);
                $this->view->assign_block_vars('articles', $article->get_tpl_vars());
                $this->build_sources_view($article);
            }
        }
        $result->dispose();
        $this->view->put('FORM', $this->form->display());
    }
    private function save()
    {
        $bug = $this->get_bug();
        if ($bug->get_id() === null) {
            $title = $this->form->get_value('title');
            $bug->set_title($title);
            $bug->set_rewrited_title(Url::encode_rewrite($title));
            $bug->set_contents($this->form->get_value('contents'));
            $bug->set_type($this->form->get_value('type') ? $this->form->get_value('type')->get_raw_value() : $this->config->get_default_type());
            $bug->set_category($this->form->get_value('category') ? $this->form->get_value('category')->get_raw_value() : $this->config->get_default_category());
            $bug->set_severity($this->form->get_value('severity') ? $this->form->get_value('severity')->get_raw_value() : $this->config->get_default_severity());
            $bug->set_priority($this->form->get_value('priority') ? $this->form->get_value('priority')->get_raw_value() : $this->config->get_default_priority());
            $bug->set_detected_in($this->form->get_value('detected_in') ? $this->form->get_value('detected_in')->get_raw_value() : $this->config->get_default_version());
            $bug->set_reproductible($this->form->get_value('reproductible') ? true : 0);
            if ($bug->is_reproductible()) {
                $bug->set_reproduction_method($this->form->get_value('reproduction_method'));
            }
            //Bug creation
            $bug->set_id(BugtrackerService::add($bug));
            if ($this->config->are_admin_alerts_enabled() && in_array($bug->get_severity(), $this->config->get_admin_alerts_levels())) {
                $alert = new AdministratorAlert();
                $alert->set_entitled('[' . $this->lang['module_title'] . '] ' . $bug->get_title());
                $alert->set_fixing_url(BugtrackerUrlBuilder::detail($bug->get_id() . '-' . $bug->get_rewrited_title())->relative());
                switch ($bug->get_priority()) {
                    case 1:
                        switch ($bug->get_severity()) {
                            case 1:
                                $alert_priority = AdministratorAlert::ADMIN_ALERT_VERY_LOW_PRIORITY;
                                break;
                            case 2:
                                $alert_priority = AdministratorAlert::ADMIN_ALERT_LOW_PRIORITY;
                                break;
                            default:
                                $alert_priority = AdministratorAlert::ADMIN_ALERT_MEDIUM_PRIORITY;
                                break;
                        }
                        break;
                    case 2:
                        switch ($bug->get_severity()) {
                            case 1:
                                $alert_priority = AdministratorAlert::ADMIN_ALERT_LOW_PRIORITY;
                                break;
                            default:
                                $alert_priority = AdministratorAlert::ADMIN_ALERT_MEDIUM_PRIORITY;
                                break;
                        }
                        break;
                    case 3:
                        switch ($bug->get_severity()) {
                            case 1:
                                $alert_priority = AdministratorAlert::ADMIN_ALERT_LOW_PRIORITY;
                                break;
                            case 2:
                                $alert_priority = AdministratorAlert::ADMIN_ALERT_MEDIUM_PRIORITY;
                                break;
                            case 3:
                                $alert_priority = AdministratorAlert::ADMIN_ALERT_HIGH_PRIORITY;
                                break;
                            default:
                                $alert_priority = AdministratorAlert::ADMIN_ALERT_MEDIUM_PRIORITY;
                                break;
                        }
                        break;
                    case 4:
                        switch ($bug->get_severity()) {
                            case 2:
                                $alert_priority = AdministratorAlert::ADMIN_ALERT_MEDIUM_PRIORITY;
                                break;
                            case 3:
                                $alert_priority = AdministratorAlert::ADMIN_ALERT_HIGH_PRIORITY;
                                break;
                            default:
                                $alert_priority = AdministratorAlert::ADMIN_ALERT_LOW_PRIORITY;
                                break;
                        }
                        break;
                    case 5:
                        switch ($bug->get_severity()) {
                            case 2:
                                $alert_priority = AdministratorAlert::ADMIN_ALERT_HIGH_PRIORITY;
                                break;
                            case 3:
                                $alert_priority = AdministratorAlert::ADMIN_ALERT_VERY_HIGH_PRIORITY;
                                break;
                            default:
                                $alert_priority = AdministratorAlert::ADMIN_ALERT_MEDIUM_PRIORITY;
                                break;
                        }
                        break;
                    default:
                        switch ($bug->get_severity()) {
                            case 1:
                                $alert_priority = AdministratorAlert::ADMIN_ALERT_LOW_PRIORITY;
                                break;
                            case 2:
                                $alert_priority = AdministratorAlert::ADMIN_ALERT_MEDIUM_PRIORITY;
                                break;
                            case 3:
                                $alert_priority = AdministratorAlert::ADMIN_ALERT_HIGH_PRIORITY;
                                break;
                            default:
                                $alert_priority = AdministratorAlert::ADMIN_ALERT_MEDIUM_PRIORITY;
                                break;
                        }
                        break;
                }
                $alert->set_priority($alert_priority);
                $alert->set_id_in_module($bug->get_id());
                $alert->set_type('bugtracker');
                AdministratorAlertService::save_alert($alert);
            }
        } else {
            $old_values = clone $bug;
            $now = new Date();
            $types = $this->config->get_types();
            $categories = $this->config->get_categories();
            $severities = $this->config->get_severities();
            $priorities = $this->config->get_priorities();
            $versions = $this->config->get_versions();
            $display_versions = count($versions) > 1;
            $status_list = $this->config->get_status_list();
            $common_lang = LangLoader::get('common');
            $title = $this->form->get_value('title', $old_values->get_title());
            $bug->set_title($title);
            $bug->set_rewrited_title(Url::encode_rewrite($title));
            $bug->set_contents($this->form->get_value('contents', $old_values->get_contents()));
            $bug->set_type($this->form->get_value('type') ? $this->form->get_value('type')->get_raw_value() : $old_values->get_type());
            $bug->set_category($this->form->get_value('category') ? $this->form->get_value('category')->get_raw_value() : $old_values->get_category());
            $bug->set_severity($this->form->get_value('severity') ? $this->form->get_value('severity')->get_raw_value() : $old_values->get_severity());
            $bug->set_priority($this->form->get_value('priority') ? $this->form->get_value('priority')->get_raw_value() : $old_values->get_priority());
            $bug->set_detected_in($this->form->get_value('detected_in') ? $this->form->get_value('detected_in')->get_raw_value() : $old_values->get_detected_in());
            $bug->set_reproductible($this->form->get_value('reproductible') ? true : 0);
            if ($bug->is_reproductible()) {
                $bug->set_reproduction_method($this->form->get_value('reproduction_method', $old_values->get_reproduction_method()));
            }
            $pm_comment = '';
            $modification = false;
            $fields = array('title', 'contents', 'type', 'category', 'severity', 'priority', 'detected_in', 'reproductible', 'reproduction_method');
            $n_values = $bug->get_properties();
            $o_values = $old_values->get_properties();
            foreach ($fields as $field) {
                if ($o_values[$field] != $n_values[$field]) {
                    $modification = true;
                    $comment = '';
                    switch ($field) {
                        case 'title':
                            $new_value = stripslashes($n_values[$field]);
                            $o_values[$field] = addslashes($o_values[$field]);
                            $comment = '';
                            break;
                        case 'contents':
                            $o_values[$field] = '';
                            $n_values[$field] = '';
                            $comment = $this->lang['notice.contents_update'];
                            break;
                        case 'reproduction_method':
                            $o_values[$field] = '';
                            $n_values[$field] = '';
                            $comment = $this->lang['notice.reproduction_method_update'];
                            break;
                        case 'type':
                            $new_value = !empty($n_values[$field]) ? stripslashes($types[$n_values[$field]]) : $this->lang['notice.none'];
                            break;
                        case 'category':
                            $new_value = !empty($n_values[$field]) ? stripslashes($categories[$n_values[$field]]) : $this->lang['notice.none_e'];
                            break;
                        case 'priority':
                            $new_value = !empty($n_values[$field]) ? stripslashes($priorities[$n_values[$field]]) : $this->lang['notice.none_e'];
                            break;
                        case 'severity':
                            $new_value = !empty($n_values[$field]) ? stripslashes($severities[$n_values[$field]]['name']) : $this->lang['notice.none'];
                            break;
                        case 'detected_in':
                            $new_value = !empty($n_values[$field]) ? stripslashes($versions[$n_values[$field]]['name']) : $this->lang['notice.none_e'];
                            break;
                        case 'status':
                            $new_value = $this->lang['status.' . $n_values[$field]];
                            break;
                        case 'reproductible':
                            $new_value = $n_values[$field] ? $common_lang['yes'] : $common_lang['no'];
                            break;
                        default:
                            $new_value = $n_values[$field];
                            $comment = '';
                    }
                    $pm_comment .= $field != 'contents' && $field != 'reproduction_method' ? $this->lang['labels.fields.' . $field] . ' : ' . stripslashes($new_value) . '
	' : '';
                    //Bug history update
                    BugtrackerService::add_history(array('bug_id' => $bug->get_id(), 'updater_id' => $this->current_user->get_id(), 'update_date' => $now->get_timestamp(), 'updated_field' => $field, 'old_value' => $o_values[$field], 'new_value' => $n_values[$field], 'change_comment' => $comment));
                }
            }
            if ($modification) {
                //Bug update
                BugtrackerService::update($bug);
                //Send PM to updaters if the option is enabled
                if ($this->config->are_pm_enabled() && $this->config->are_pm_edit_enabled() && !empty($pm_comment)) {
                    BugtrackerPMService::send_PM_to_updaters('edit', $bug->get_id(), $pm_comment);
                }
            }
        }
        Feed::clear_cache('bugtracker');
        BugtrackerStatsCache::invalidate();
        AppContext::get_response()->redirect($this->form->get_value('referrer') ? $this->form->get_value('referrer') : BugtrackerUrlBuilder::unsolved(), StringVars::replace_vars($this->is_new_bug ? $this->lang['success.add'] : $this->lang['success.edit'], array('id' => $bug->get_id())));
    }
 /**
  * @method Get fix versions
  */
 public function get_versions_fix()
 {
     $now = new Date();
     $versions = $this->get_property(self::VERSIONS);
     $versions_fix = array();
     foreach ($versions as $key => $version) {
         $release_date = !empty($version['release_date']) && is_numeric($version['release_date']) ? new Date($version['release_date'], Timezone::SERVER_TIMEZONE) : null;
         if (empty($release_date) || $release_date->get_timestamp() >= $now->get_timestamp()) {
             $versions_fix[$key] = $version;
         }
     }
     return $versions_fix;
 }
示例#22
0
if ($file_id > 0) {
    $Template->set_filenames(array('download' => 'download/download.tpl'));
    if ($download_info['size'] > 1) {
        $size_tpl = $download_info['size'] . ' ' . $LANG['unit_megabytes'];
    } elseif ($download_info['size'] > 0) {
        $size_tpl = $download_info['size'] * 1024 . ' ' . $LANG['unit_kilobytes'];
    } else {
        $size_tpl = $DOWNLOAD_LANG['unknown_size'];
    }
    import('util/date');
    $creation_date = new Date(DATE_TIMESTAMP, TIMEZONE_SYSTEM, $download_info['timestamp']);
    $release_date = new Date(DATE_TIMESTAMP, TIMEZONE_SYSTEM, $download_info['release_timestamp']);
    import('content/note');
    $Note = new Note('download', $file_id, url('download.php?id=' . $file_id, 'category-' . $category_id . '-' . $file_id . '.php'), $CONFIG_DOWNLOAD['note_max'], '', NOTE_NODISPLAY_NBRNOTES);
    import('content/comments');
    $Template->assign_vars(array('C_DISPLAY_DOWNLOAD' => true, 'C_IMG' => !empty($download_info['image']), 'C_EDIT_AUTH' => $auth_write, 'MODULE_DATA_PATH' => $Template->get_module_data_path('download'), 'ID_FILE' => $file_id, 'NAME' => $download_info['title'], 'CONTENTS' => second_parse($download_info['contents']), 'CREATION_DATE' => $creation_date->format(DATE_FORMAT_SHORT), 'RELEASE_DATE' => $release_date->get_timestamp() > 0 ? $release_date->format(DATE_FORMAT_SHORT) : $DOWNLOAD_LANG['unknown_date'], 'SIZE' => $size_tpl, 'COUNT' => $download_info['count'], 'THEME' => get_utheme(), 'KERNEL_NOTATION' => $Note->display_form(), 'HITS' => sprintf($DOWNLOAD_LANG['n_times'], (int) $download_info['count']), 'NUM_NOTES' => sprintf($DOWNLOAD_LANG['num_notes'], (int) $download_info['nbrnote']), 'U_IMG' => $download_info['image'], 'IMAGE_ALT' => str_replace('"', '\\"', $download_info['title']), 'LANG' => get_ulang(), 'U_COM' => Comments::com_display_link($download_info['nbr_com'], '../download/download' . url('.php?id=' . $file_id . '&amp;com=0', '-' . $file_id . '+' . url_encode_rewrite($download_info['title']) . '.php?com=0'), $file_id, 'download'), 'L_DATE' => $LANG['date'], 'L_SIZE' => $LANG['size'], 'L_DOWNLOAD' => $DOWNLOAD_LANG['download'], 'L_DOWNLOAD_FILE' => $DOWNLOAD_LANG['download_file'], 'L_FILE_INFOS' => $DOWNLOAD_LANG['file_infos'], 'L_INSERTION_DATE' => $DOWNLOAD_LANG['insertion_date'], 'L_RELEASE_DATE' => $DOWNLOAD_LANG['last_update_date'], 'L_DOWNLOADED' => $DOWNLOAD_LANG['downloaded'], 'L_EDIT_FILE' => str_replace('"', '\\"', $DOWNLOAD_LANG['edit_file']), 'L_CONFIRM_DELETE_FILE' => str_replace('\'', '\\\'', $DOWNLOAD_LANG['confirm_delete_file']), 'L_DELETE_FILE' => str_replace('"', '\\"', $DOWNLOAD_LANG['delete_file']), 'U_EDIT_FILE' => url('management.php?edit=' . $file_id), 'U_DELETE_FILE' => url('management.php?del=' . $file_id . '&amp;token=' . $Session->get_token()), 'U_DOWNLOAD_FILE' => url('count.php?id=' . $file_id, 'file-' . $file_id . '+' . url_encode_rewrite($download_info['title']) . '.php')));
    if (isset($_GET['com'])) {
        $Template->assign_vars(array('COMMENTS' => display_comments('download', $file_id, url('download.php?id=' . $file_id . '&amp;com=%s', 'download-' . $file_id . '.php?com=%s'))));
    }
    $Template->pparse('download');
} else {
    $Template->set_filenames(array('download' => 'download/download.tpl'));
    $Template->assign_vars(array('C_ADMIN' => $auth_write, 'C_DOWNLOAD_CAT' => true, 'C_ADD_FILE' => $auth_write || $auth_contribution, 'C_DESCRIPTION' => !empty($DOWNLOAD_CATS[$category_id]['contents']) || $category_id == 0 && !empty($CONFIG_DOWNLOAD['root_contents']), 'IDCAT' => $category_id, 'TITLE' => sprintf($DOWNLOAD_LANG['title_download'] . ($category_id > 0 ? ' - ' . $DOWNLOAD_CATS[$category_id]['name'] : '')), 'DESCRIPTION' => $category_id > 0 ? second_parse($DOWNLOAD_CATS[$category_id]['contents']) : second_parse($CONFIG_DOWNLOAD['root_contents']), 'L_ADD_FILE' => $DOWNLOAD_LANG['add_file'], 'U_ADMIN_CAT' => $category_id > 0 ? url('admin_download_cat.php?edit=' . $category_id) : url('admin_download_cat.php'), 'U_ADD_FILE' => url('management.php?new=1&amp;idcat=' . $category_id)));
    $num_subcats = 0;
    foreach ($DOWNLOAD_CATS as $id => $value) {
        if ($id != 0 && $value['id_parent'] == $category_id) {
            $num_subcats++;
        }
    }
    if ($num_subcats > 0) {
        $Template->assign_vars(array('C_SUB_CATS' => true));
示例#23
0
 }
 if (!empty($errstr)) {
     $tpl->put('message_helper', MessageHelper::display($errstr, $type));
 }
 //Si le cookie existe, ou l'ip est connue on redirige vers les resulats, sinon on prend en compte le vote.
 $array_cookie = array();
 if (AppContext::get_request()->has_cookieparameter($config_cookie_name)) {
     $array_cookie = explode('/', AppContext::get_request()->get_cookie($config_cookie_name));
 }
 if ($show_result || in_array($poll['id'], $array_cookie) === true || $check_bdd) {
     $array_answer = explode('|', $poll['answers']);
     $array_vote = explode('|', $poll['votes']);
     $poll_creation_date = new Date($poll['timestamp'], Timezone::SERVER_TIMEZONE);
     $poll_end_date = new Date($poll['end'], Timezone::SERVER_TIMEZONE);
     $is_admin = AppContext::get_current_user()->check_level(User::ADMIN_LEVEL);
     $results_displayed = $poll_config->are_results_displayed_before_polls_end() && !empty($poll['end']) ? $now->get_timestamp() > $poll_end_date->get_timestamp : true;
     $sum_vote = array_sum($array_vote);
     $tpl->put_all(array('C_POLL_VIEW' => true, 'C_POLL_RESULTS' => true, 'C_IS_ADMIN' => $is_admin, 'C_DISPLAY_RESULTS' => $is_admin || $results_displayed && (!empty($nbr_votes) || !empty($ip)), 'C_NO_VOTE' => !$is_admin && (empty($nbr_votes) && empty($ip)), 'IDPOLL' => $poll['id'], 'QUESTION' => stripslashes($poll['question']), 'DATE' => $poll_creation_date->format(Date::FORMAT_DAY_MONTH_YEAR), 'VOTES' => $sum_vote, 'L_POLL' => $LANG['poll'], 'L_BACK_POLL' => $LANG['poll_back'], 'L_VOTE' => $sum_vote > 1 ? $LANG['poll_vote_s'] : $LANG['poll_vote'], 'L_ON' => $LANG['on'], 'L_NO_VOTE' => $LANG['e_no_vote'], 'L_RESULTS_NOT_DISPLAYED_YET' => StringVars::replace_vars($LANG['e_results_not_displayed_yet'], array('end_date' => $poll_end_date->format(Date::FORMAT_DAY_MONTH_YEAR))), 'L_EDIT' => LangLoader::get_message('edit', 'common'), 'L_DELETE' => LangLoader::get_message('delete', 'common')));
     $sum_vote = $sum_vote == 0 ? 1 : $sum_vote;
     //Empêche la division par 0.
     $array_poll = array_combine($array_answer, $array_vote);
     foreach ($array_poll as $answer => $nbrvote) {
         $tpl->assign_block_vars('result', array('ANSWERS' => $answer, 'NBRVOTE' => (int) $nbrvote, 'WIDTH' => NumberHelper::round($nbrvote * 100 / $sum_vote, 1) * 4, 'PERCENT' => NumberHelper::round($nbrvote * 100 / $sum_vote, 1)));
     }
     $tpl->display();
 } else {
     $tpl->put_all(array('C_POLL_VIEW' => true, 'C_POLL_QUESTION' => true, 'C_IS_ADMIN' => AppContext::get_current_user()->check_level(User::ADMIN_LEVEL), 'IDPOLL' => $poll['id'], 'QUESTION' => stripslashes($poll['question']), 'VOTES' => 0, 'ID_R' => url('.php?id=' . $poll['id'] . '&amp;r=1', '-' . $poll['id'] . '-1.php'), 'QUESTION' => stripslashes($poll['question']), 'DATE' => Date::to_format($poll['timestamp'], Date::FORMAT_DAY_MONTH_YEAR), 'U_POLL_ACTION' => url('.php?id=' . $poll['id'], '-' . $poll['id'] . '.php'), 'U_POLL_RESULT' => url('.php?id=' . $poll['id'] . '&amp;r=1', '-' . $poll['id'] . '-1.php'), 'L_POLL' => $LANG['poll'], 'L_BACK_POLL' => $LANG['poll_back'], 'L_VOTE' => $LANG['poll_vote'], 'L_RESULT' => $LANG['poll_result'], 'L_EDIT' => LangLoader::get_message('edit', 'common'), 'L_DELETE' => LangLoader::get_message('delete', 'common'), 'L_ON' => $LANG['on']));
     $z = 0;
     $array_answer = explode('|', $poll['answers']);
     if ($poll['type'] == '1') {
         foreach ($array_answer as $answer) {
示例#24
0
 public function test_to_date()
 {
     $date = new Date();
     $time = time();
     self::assertEquals($time, $date->get_timestamp());
     self::assertEquals(date('Y-m-d', $time), $date->to_date());
 }
    private function build_categories_listing_view(Date $now, $field, $mode, $page, $subcategories_page)
    {
        $authorized_categories = ArticlesService::get_authorized_categories($this->get_category()->get_id());
        $subcategories_number = count(ArticlesService::get_categories_manager()->get_categories_cache()->get_childrens($this->category->get_id()));
        $pagination = $this->get_subcategories_pagination($subcategories_number, $this->config->get_number_categories_per_page(), $field, $mode, $page, $subcategories_page);
        $result = PersistenceContext::get_querier()->select('SELECT @id_cat:= id, articles_cats.*,
		(SELECT COUNT(*) FROM ' . ArticlesSetup::$articles_table . '
			WHERE id_category IN (
				@id_cat,
				(SELECT GROUP_CONCAT(id SEPARATOR \',\') FROM ' . ArticlesSetup::$articles_cats_table . ' WHERE id_parent = @id_cat), 
				(SELECT GROUP_CONCAT(childs.id SEPARATOR \',\') FROM ' . ArticlesSetup::$articles_cats_table . ' parents
				INNER JOIN ' . ArticlesSetup::$articles_cats_table . ' childs ON parents.id = childs.id_parent
				WHERE parents.id_parent = @id_cat)
			)
			AND (published = 1 OR (published = 2 AND publishing_start_date < :timestamp_now AND (publishing_end_date > :timestamp_now OR publishing_end_date = 0)))
		) AS articles_number
		FROM ' . ArticlesSetup::$articles_cats_table . ' articles_cats
		WHERE id_parent = :id_category AND id IN :authorized_categories
		ORDER BY id_parent, c_order
		LIMIT :number_items_per_page OFFSET :display_from', array('timestamp_now' => $now->get_timestamp(), 'id_category' => $this->category->get_id(), 'authorized_categories' => $authorized_categories, 'number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from()));
        $nbr_cat_displayed = 0;
        while ($row = $result->fetch()) {
            $category_image = new Url($row['image']);
            $this->view->assign_block_vars('sub_categories_list', array('C_CATEGORY_IMAGE' => !empty($row['image']), 'C_MORE_THAN_ONE_ARTICLE' => $row['articles_number'] > 1, 'CATEGORY_NAME' => $row['name'], 'CATEGORY_IMAGE' => $category_image->rel(), 'ARTICLES_NUMBER' => $row['articles_number'], 'U_CATEGORY' => ArticlesUrlBuilder::display_category($row['id'], $row['rewrited_name'])->rel()));
            if (!empty($row['id'])) {
                $nbr_cat_displayed++;
            }
        }
        $result->dispose();
        $nbr_column_cats = $nbr_cat_displayed > $this->config->get_number_cols_display_cats() ? $this->config->get_number_cols_display_cats() : $nbr_cat_displayed;
        $nbr_column_cats = !empty($nbr_column_cats) ? $nbr_column_cats : 1;
        $cats_columns_width = floor(100 / $nbr_column_cats);
        $category_description = FormatingHelper::second_parse($this->get_category()->get_description());
        $this->view->put_all(array('C_CATEGORY' => true, 'C_ROOT_CATEGORY' => $this->get_category()->get_id() == Category::ROOT_CATEGORY, 'C_HIDE_NO_ITEM_MESSAGE' => $this->get_category()->get_id() == Category::ROOT_CATEGORY && ($nbr_cat_displayed != 0 || !empty($category_description)), 'C_CATEGORY_DESCRIPTION' => !empty($category_description), 'C_SUB_CATEGORIES' => $nbr_cat_displayed > 0, 'C_SUBCATEGORIES_PAGINATION' => $pagination->has_several_pages(), 'CATEGORY_NAME' => $this->get_category()->get_name(), 'CATEGORY_IMAGE' => $this->get_category()->get_image()->rel(), 'CATEGORY_DESCRIPTION' => $category_description, 'SUBCATEGORIES_PAGINATION' => $pagination->display(), 'CATS_COLUMNS_WIDTH' => $cats_columns_width));
    }
示例#26
0
            $end_calendar->set_date(new Date(DATE_TIMESTAMP, TIMEZONE_AUTO, $news_infos['end']));
        } elseif (!empty($news_infos['visible'])) {
            $news_visibility = 1;
        } else {
            $news_visibility = 0;
        }
        $Template->assign_vars(array('TITLE' => $news_infos['title'], 'COUNT' => !empty($news_infos['count']) ? $news_infos['count'] : 0, 'DESCRIPTION' => unparse($news_infos['contents']), 'SHORT_DESCRIPTION' => unparse($news_infos['short_contents']), 'FILE_IMAGE' => $news_infos['image'], 'URL' => $news_infos['url'], 'SIZE_FORM' => $news_infos['size'], 'DATE' => $news_creation_date->format(DATE_FORMAT_SHORT, TIMEZONE_AUTO), 'CATEGORIES_TREE' => $news_categories->build_select_form($news_infos['idcat'], 'idcat', 'idcat', 0, WRITE_CAT_NEWS, $CONFIG_NEWS['global_auth'], IGNORE_AND_CONTINUE_BROWSING_IF_A_CATEGORY_DOES_NOT_MATCH), 'DATE_CALENDAR_CREATION' => $creation_calendar->display(), 'DATE_CALENDAR_RELEASE' => $release_calendar->display(), 'BOOL_IGNORE_RELEASE_DATE' => $ignore_release_date ? 'true' : 'false', 'STYLE_FIELD_RELEASE_DATE' => $ignore_release_date ? 'none' : 'block', 'IGNORE_RELEASE_DATE_CHECKED' => $ignore_release_date ? ' checked="checked"' : '', 'BEGINING_CALENDAR' => $begining_calendar->display(), 'END_CALENDAR' => $end_calendar->display(), 'VISIBLE_WAITING' => $news_visibility == 2 ? ' checked="checked"' : '', 'VISIBLE_ENABLED' => $news_visibility == 1 ? ' checked="checked"' : '', 'VISIBLE_UNAPROVED' => $news_visibility == 0 ? ' checked="checked"' : '', 'U_TARGET' => url('management.php?edit=' . $edit_news_id . '&amp;token=' . $Session->get_token())));
    }
} elseif ($add_news) {
    if ($submit) {
        if (!empty($news_title) && $news_categories->check_auth($news_cat_id) && !empty($news_url) && !empty($news_contents)) {
            $visible = 1;
            $date_now = new Date(DATE_NOW);
            switch ($news_visibility) {
                case 2:
                    if ($begining_date->get_timestamp() < $date_now->get_timestamp() && $end_date->get_timestamp() > $date_now->get_timestamp()) {
                        $start_timestamp = $begining_date->get_timestamp();
                        $end_timestamp = $end_date->get_timestamp();
                    } else {
                        $visible = 0;
                    }
                    break;
                case 1:
                    list($start_timestamp, $end_timestamp) = array(0, 0);
                    break;
                default:
                    list($visible, $start_timestamp, $end_timestamp) = array(0, 0, 0);
            }
            $Sql->query_inject("INSERT INTO " . PREFIX . "news (title, idcat, url, size, count, contents, short_contents, image, timestamp, release_timestamp, start, end, visible) VALUES ('" . $news_title . "', '" . $news_cat_id . "', '" . $news_url . "', '" . $news_size . "', '" . $news_hits . "', '" . strparse($news_contents) . "', '" . strparse($news_short_contents) . "', '" . $news_image . "', '" . $news_creation_date->get_timestamp() . "', '" . ($ignore_release_date ? 0 : $news_release_date->get_timestamp()) . "', '" . $start_timestamp . "', '" . $end_timestamp . "', '" . $visible . "')", __LINE__, __FILE__);
            $new_id_news = $Sql->insert_id("SELECT MAX(id) FROM " . PREFIX . "news");
            if ($news_cat_id != $news_infos['idcat']) {
示例#27
0
文件: Pdf.php 项目: ajaboa/crmpuan
 public function Header()
 {
     if (is_callable($this->headerFunction)) {
         call_user_func($this->headerFunction);
         return;
     }
     $this->SetY(10);
     // DEZE WAS T
     //		$this->SetTextColor(50,135,172);
     $this->SetFont($this->font, 'B', 16);
     if (!empty($this->title)) {
         $this->Write(16, $this->title);
     }
     if (!empty($this->subtitle)) {
         $this->SetTextColor(125, 162, 180);
         $this->SetFont($this->font, '', 12);
         $this->setXY($this->getX() + 5, $this->getY() + 3.5);
         $this->Write(12, $this->subtitle);
     }
     $this->setY($this->getY() + 2.5, false);
     $this->SetFont($this->font, '', $this->font_size);
     $this->setDefaultTextColor();
     $this->Cell($this->getPageWidth() - $this->getX() - $this->rMargin, 12, Date::get_timestamp(time()), 0, 0, 'R');
     if (!empty($_REQUEST['text'])) {
         $this->SetFont($this->font, '', $this->font_size);
         $this->Ln(20);
         $this->MultiCell($this->getPageWidth(), 12, $_REQUEST['text']);
     }
     if (!empty($_REQUEST['html'])) {
         $this->SetFont($this->font, '', $this->font_size);
         $this->Ln(20);
         $this->writeHTML($_REQUEST['html']);
     }
     if (empty($_REQUEST['text']) && empty($_REQUEST['html'])) {
         $this->Ln();
     }
     $this->SetTopMargin($this->getY() + 10);
 }
 /**
  * @desc Create or updates an alert in the database. It creates it whether it doesn't exist or updates it if it already exists.
  * @param AdministratorAlert $alert The alert to create or update.
  */
 public static function save_alert($alert)
 {
     // If it exists already in the data base
     if ($alert->get_id() > 0) {
         //This line exists only to be compatible with PHP 4 (we cannot use $var->get_var()->method(), whe have to use a temp var)
         $creation_date = $alert->get_creation_date();
         self::$db_querier->update(DB_TABLE_EVENTS, array('entitled' => $alert->get_entitled(), 'description' => $alert->get_properties(), 'fixing_url' => $alert->get_fixing_url(), 'current_status' => $alert->get_status(), 'creation_date' => $creation_date->get_timestamp(), 'id_in_module' => $alert->get_id_in_module(), 'identifier' => $alert->get_identifier(), 'type' => $alert->get_type(), 'priority' => $alert->get_priority()), 'WHERE id = :id', array('id' => $alert->get_id()));
         //Regeneration of the member cache file
         if ($alert->get_must_regenerate_cache()) {
             AdministratorAlertCache::invalidate();
             $alert->set_must_regenerate_cache(false);
         }
     } else {
         $creation_date = new Date();
         $result = self::$db_querier->insert(DB_TABLE_EVENTS, array('entitled' => $alert->get_entitled(), 'description' => $alert->get_properties(), 'fixing_url' => $alert->get_fixing_url(), 'current_status' => $alert->get_status(), 'creation_date' => $creation_date->get_timestamp(), 'id_in_module' => $alert->get_id_in_module(), 'identifier' => $alert->get_identifier(), 'type' => $alert->get_type(), 'priority' => $alert->get_priority()));
         $alert->set_id($result->get_last_inserted_id());
         //Cache regeneration
         AdministratorAlertCache::invalidate();
     }
 }
示例#29
0
                //Sons
            //Sons
            case 'mp3':
                $bbcode = '[sound]/upload/' . $row['path'] . '[/sound]';
                $tinymce = '<a href="' . PATH_TO_ROOT . '/upload/' . $row['path'] . '">' . $row['name'] . '</a>';
                $link = '/upload/' . $row['path'];
                break;
            default:
                $bbcode = '[url=/upload/' . $row['path'] . ']' . $row['name'] . '[/url]';
                $tinymce = '<a href="' . PATH_TO_ROOT . '/upload/' . $row['path'] . '">' . $row['name'] . '</a>';
                $link = '/upload/' . $row['path'];
        }
        $is_bbcode_editor = $editor == 'BBCode';
        $displayed_code = $is_bbcode_editor ? $bbcode : '/upload/' . $row['path'];
        $inserted_code = !empty($parse) ? !empty($no_path) ? $link : PATH_TO_ROOT . $link : ($is_bbcode_editor ? addslashes($bbcode) : TextHelper::htmlentities($tinymce));
        $tpl->assign_block_vars('files', array('C_RECENT_FILE' => $row['timestamp'] > $now->get_timestamp() - 15 * 60, 'ID' => $row['id'], 'IMG' => $get_img_mimetype['img'], 'URL' => PATH_TO_ROOT . $link, 'TITLE' => str_replace('"', '\\"', $row['name']), 'NAME' => $name_cut, 'RENAME_FILE' => '<span id="fihref' . $row['id'] . '"><a href="javascript:display_rename_file(\'' . $row['id'] . '\', \'' . addslashes($row['name']) . '\', \'' . addslashes($name_cut) . '\');" title="' . LangLoader::get_message('edit', 'common') . '" class="fa fa-edit"></a></span>', 'FILETYPE' => $get_img_mimetype['filetype'] . $size_img, 'BBCODE' => '<input type="text" readonly="readonly" onclick="select_div(\'text_' . $row['id'] . '\');" id="text_' . $row['id'] . '" class="upload-input-bbcode" value="' . $displayed_code . '">', 'SIZE' => $row['size'] > 1024 ? NumberHelper::round($row['size'] / 1024, 2) . ' ' . LangLoader::get_message('unit.megabytes', 'common') : NumberHelper::round($row['size'], 0) . ' ' . LangLoader::get_message('unit.kilobytes', 'common'), 'INSERT' => !empty($popup) ? '<a href="javascript:insert_popup(\'' . $inserted_code . '\')" title="' . $LANG['popup_insert'] . '" class="fa fa-clipboard"></a>' : '', 'LIGHTBOX' => !empty($size_img) ? ' data-lightbox="1"' : '', 'U_MOVE' => url('.php?movefi=' . $row['id'] . '&amp;f=' . $folder . $popup)));
        $total_folder_size += $row['size'];
        $total_files++;
    }
    $result->dispose();
    //Autorisation d'uploader sans limite aux groupes.
    $group_limit = AppContext::get_current_user()->check_max_value(DATA_GROUP_LIMIT, $files_upload_config->get_maximum_size_upload());
    $unlimited_data = $group_limit === -1 || AppContext::get_current_user()->check_level(User::ADMIN_LEVEL);
    $total_size = !empty($folder) ? Uploads::Member_memory_used(AppContext::get_current_user()->get_id()) : PersistenceContext::get_querier()->get_column_value(DB_TABLE_UPLOAD, 'SUM(size)', 'WHERE user_id = :id', array('id' => AppContext::get_current_user()->get_id()));
    $tpl->put_all(array('PERCENT' => !$unlimited_data ? '(' . NumberHelper::round($total_size / $group_limit, 3) * 100 . '%)' : '', 'SIZE_LIMIT' => !$unlimited_data ? $group_limit > 1024 ? NumberHelper::round($group_limit / 1024, 2) . ' ' . LangLoader::get_message('unit.megabytes', 'common') : NumberHelper::round($group_limit, 0) . ' ' . LangLoader::get_message('unit.kilobytes', 'common') : $LANG['illimited'], 'TOTAL_SIZE' => $total_size > 1024 ? NumberHelper::round($total_size / 1024, 2) . ' ' . LangLoader::get_message('unit.megabytes', 'common') : NumberHelper::round($total_size, 0) . ' ' . LangLoader::get_message('unit.kilobytes', 'common'), 'TOTAL_FOLDER_SIZE' => $total_folder_size > 1024 ? NumberHelper::round($total_folder_size / 1024, 2) . ' ' . LangLoader::get_message('unit.megabytes', 'common') : NumberHelper::round($total_folder_size, 0) . ' ' . LangLoader::get_message('unit.kilobytes', 'common'), 'TOTAL_FOLDERS' => $total_directories, 'TOTAL_FILES' => $total_files));
    if ($total_directories == 0 && $total_files == 0) {
        $tpl->put_all(array('C_EMPTY_FOLDER' => true, 'L_EMPTY_FOLDER' => LangLoader::get_message('no_item_now', 'common')));
    }
    $tpl->display();
}
if (empty($popup)) {