diff --git a/Gruntfile.js b/Gruntfile.js index caab837758c..bf7dbd8f247 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -43,6 +43,13 @@ module.exports = function(grunt) { 'rsc/less/bootstrap-evoskins.less' // Common styles for all bootstrap skins ], + // Superbundle Font-Awesome + Bootstrap + Front-office styles: + 'rsc/build/bootstrap-b2evo_base-superbundle.bundle.css': [ + 'rsc/ext/font-awesome/css/font-awesome.css', + 'rsc/ext/bootstrap/css/bootstrap.css', + 'rsc/build/bootstrap-b2evo_base.bundle.css', + ], + // Bootstrap back-office styles: 'rsc/build/bootstrap-backoffice-b2evo_base.bundle.css': [ // Basic styles for all bootstrap skins @@ -52,6 +59,13 @@ module.exports = function(grunt) { 'rsc/less/bootstrap-evoskins.less' // Common styles for all bootstrap skins ], + // Back-office bootstrap skin styles: + 'skins_adm/bootstrap/rsc/css/style.bundle.css': [ + 'skins_adm/bootstrap/rsc/css/style.less', + 'rsc/less/inc/jquery.easy-pie-chart.inc.less', + 'rsc/less/inc/jquery.jqplot.inc.less', + ], + // Bootstrap skins 'skins/green_bootstrap_theme/style.css': 'skins/green_bootstrap_theme/style.less', 'skins/green_bootstrap_theme/std/style.css': 'skins/green_bootstrap_theme/std/style.less', @@ -78,11 +92,17 @@ module.exports = function(grunt) { 'rsc/build/b2evo_helper_screens.css': 'rsc/less/b2evo_helper_screens.less', // Colorbox - 'rsc/css/colorbox/colorbox-regular.css': 'rsc/css/colorbox/colorbox-regular.less', - 'rsc/css/colorbox/colorbox-bootstrap.css': 'rsc/css/colorbox/colorbox-bootstrap.less', + 'rsc/customized/jquery/colorbox/css/colorbox-regular.css': 'rsc/customized/jquery/colorbox/css/colorbox-regular.less', + 'rsc/customized/jquery/colorbox/css/colorbox-bootstrap.css': 'rsc/customized/jquery/colorbox/css/colorbox-bootstrap.less', // evo helpdesk widget 'rsc/css/evo_helpdesk_widget.css': 'rsc/less/evo_helpdesk_widget.less', + + // info dots plugin + 'plugins/infodots_plugin/infodots.css': 'plugins/infodots_plugin/infodots.less', + + // Video plugin + 'plugins/videoplug_plugin/css/videoplug.css': 'plugins/videoplug_plugin/css/videoplug.less', } }, @@ -135,7 +155,7 @@ module.exports = function(grunt) { */ // Login screen: sha1_md5: { - src: ['rsc/js/src/sha1.js', 'rsc/js/src/md5.js', 'rsc/js/src/twin-bcrypt.js'], + src: ['rsc/ext/sha1.js', 'rsc/ext/md5.js', 'rsc/ext/twin-bcrypt.js'], dest: 'rsc/js/build/sha1_md5.bundle.js', }, }, @@ -154,11 +174,21 @@ module.exports = function(grunt) { src: 'rsc/build/bootstrap-b2evo_base.bundle.css', dest: 'rsc/build/bootstrap-b2evo_base.bmin.css', }, + bootstrap_b2evo_base_superbundle: { + nonull: true, // Display missing files + src: 'rsc/build/bootstrap-b2evo_base-superbundle.bundle.css', + dest: 'rsc/build/bootstrap-b2evo_base-superbundle.bmin.css', + }, bootstrap_backoffice_b2evo_base: { nonull: true, // Display missing files src: 'rsc/build/bootstrap-backoffice-b2evo_base.bundle.css', dest: 'rsc/build/bootstrap-backoffice-b2evo_base.bmin.css', }, + backoffice_bootstrap_skin_style: { + nonull: true, // Display missing files + src: 'skins_adm/bootstrap/rsc/css/style.bundle.css', + dest: 'skins_adm/bootstrap/rsc/css/style.bmin.css', + }, bootstrap_skins: { files: { // Bootstrap skins @@ -186,8 +216,8 @@ module.exports = function(grunt) { }, colorbox: { files: { - 'rsc/build/colorbox-regular.min.css': 'rsc/css/colorbox/colorbox-regular.css', - 'rsc/build/colorbox-bootstrap.min.css': 'rsc/css/colorbox/colorbox-bootstrap.css', + 'rsc/build/colorbox-regular.min.css': 'rsc/customized/jquery/colorbox/css/colorbox-regular.css', + 'rsc/build/colorbox-bootstrap.min.css': 'rsc/customized/jquery/colorbox/css/colorbox-bootstrap.css', } }, ddexitpop: { @@ -202,6 +232,14 @@ module.exports = function(grunt) { src: 'rsc/build/b2evo_helper_screens.css', dest: 'rsc/build/b2evo_helper_screens.min.css', }, + jqplot: { + src: [ 'rsc/ext/jquery/jqplot/css/jquery.jqplot.css', 'rsc/ext/jquery/jqplot/css/jquery.jqplot.b2evo.css' ], + dest: 'rsc/build/b2evo_jqplot.bmin.css', + }, + videoplug: { + src: 'plugins/videoplug_plugin/css/videoplug.css', + dest: 'plugins/videoplug_plugin/css/videoplug.min.css', + } }, // Configuration for the uglify minifying tasks: @@ -223,11 +261,11 @@ module.exports = function(grunt) { // TinyMCE tinymce: { files: { - 'rsc/js/tiny_mce/plugins/image/plugin.min.js': 'rsc/js/tiny_mce/plugins/image/plugin.js', - 'rsc/js/tiny_mce/plugins/link/plugin.min.js': 'rsc/js/tiny_mce/plugins/link/plugin.js', - 'rsc/js/tiny_mce/plugins/b2evo_attachments/plugin.min.js': 'rsc/js/tiny_mce/plugins/b2evo_attachments/plugin.js', - 'rsc/js/tiny_mce/plugins/b2evo_shorttags/plugin.min.js': 'rsc/js/tiny_mce/plugins/b2evo_shorttags/plugin.js', - 'rsc/js/tiny_mce/plugins/evo_view/plugin.min.js': 'rsc/js/tiny_mce/plugins/evo_view/plugin.js', + 'rsc/ext/tiny_mce/plugins/image/plugin.min.js': 'rsc/ext/tiny_mce/plugins/image/plugin.js', + 'rsc/ext/tiny_mce/plugins/link/plugin.min.js': 'rsc/ext/tiny_mce/plugins/link/plugin.js', + 'rsc/ext/tiny_mce/plugins/b2evo_attachments/plugin.min.js': 'rsc/ext/tiny_mce/plugins/b2evo_attachments/plugin.js', + 'rsc/ext/tiny_mce/plugins/b2evo_shorttags/plugin.min.js': 'rsc/ext/tiny_mce/plugins/b2evo_shorttags/plugin.js', + 'rsc/ext/tiny_mce/plugins/evo_view/plugin.min.js': 'rsc/ext/tiny_mce/plugins/evo_view/plugin.js', 'plugins/tinymce_plugin/js/evo_view_shortcodes.bmin.js': ['plugins/tinymce_plugin/js/shortcodes.js', 'plugins/tinymce_plugin/js/evo_view.js'], } }, @@ -238,7 +276,7 @@ module.exports = function(grunt) { banner: '/* This includes 4 files: jquery.colorbox.js, voting.js, jquery.touchswipe.js, colorbox.init.js */\n' }, nonull: true, // Display missing files - src: ['rsc/js/colorbox/jquery.colorbox.js', 'rsc/js/voting.js', 'rsc/js/jquery/jquery.touchswipe.js', 'rsc/js/colorbox/colorbox.init.js'], + src: ['rsc/customized/jquery/colorbox/js/jquery.colorbox.js', 'rsc/js/voting.js', 'rsc/ext/jquery/touchswipe/jquery.touchswipe.js', 'rsc/js/colorbox.init.js'], dest: 'rsc/js/build/colorbox.bmin.js' }, // Bubbletip @@ -267,16 +305,59 @@ module.exports = function(grunt) { banner: '/* This includes 2 files: jquery.textcomplete.js, textcomplete.init.js */\n' }, nonull: true, // Display missing files - src: ['rsc/js/jquery/jquery.textcomplete.js', 'rsc/js/textcomplete.init.js'], + src: ['rsc/ext/jquery/textcomplete/jquery.textcomplete.js', 'rsc/ext/jquery/textcomplete/textcomplete.init.js'], dest: 'rsc/js/build/textcomplete.bmin.js' }, + // JS files that are used marketing popup container: + ddexitpop: { + options: { banner: '/* This includes ddexitpop files to initialize marketing popup container */\n' }, + nonull: true, // Display missing files + src: ['rsc/js/src/ddexitpop.js', 'rsc/js/src/evo_init_ddexitpop.js'], + dest: 'rsc/js/build/ddexitpop.bmin.js' + }, + // JS files that may be used on ANY page of front-office and back-office + evo_generic: { + options: { + banner: '/* This file includes ALL generic files that may be used on any page of front-office and back-office */\n' + }, + nonull: true, // Display missing files + src: [ + 'rsc/js/src/evo_generic_functions.js', + 'rsc/js/src/evo_init_generic_jquery_ready_functions.js', + 'rsc/js/src/evo_init_password_indicator.js', + 'rsc/js/src/evo_init_password_edit.js', + 'rsc/js/src/evo_init_login_validator.js', + 'rsc/js/src/evo_init_skin_bootstrap_forums.js', + 'rsc/js/src/evo_init_autocomplete_login.js', + 'rsc/js/src/evo_init_widget_poll.js', + 'rsc/js/src/evo_init_widget_item_checklist_lines.js', + 'rsc/js/src/evo_init_plugin_auto_anchors.js', + 'rsc/js/src/evo_init_plugin_custom_tags.js', + 'rsc/js/src/evo_init_plugin_table_contents.js', + 'rsc/js/src/evo_init_plugin_shortlinks.js', + 'rsc/js/src/evo_init_plugin_inlines.js', + 'rsc/js/src/evo_init_plugin_markdown.js', + 'rsc/js/src/evo_init_plugin_polls.js', + 'rsc/js/src/evo_init_plugin_shortcodes.js', + 'rsc/js/src/evo_init_plugin_widescroll.js', + 'rsc/js/src/evo_init_plugin_videoplug.js', + 'rsc/js/src/evo_init_editable_column.js', + 'rsc/js/src/evo_init_regional.js', + 'rsc/js/src/evo_init_bootstrap_tooltips.js', + 'rsc/js/src/evo_comment_funcs.js', + 'rsc/js/src/evo_user_funcs.js', + 'rsc/js/build/colorbox.bmin.js', + ], + dest: 'rsc/js/build/evo_generic.bmin.js' + }, // JS files that are used on front-office standard skins: evo_frontoffice: { options: { - banner: '/* This includes 10 files: src/evo_modal_window.js, src/evo_images.js, src/evo_user_crop.js, src/evo_user_report.js, src/evo_user_contact_groups.js, src/evo_rest_api.js, src/evo_item_flag.js, src/evo_links.js, src/evo_forms.js, ajax.js */\n' + banner: '/* This includes 11 files: build/evo_generic.bmin.js, src/evo_modal_window.js, src/evo_images.js, src/evo_user_crop.js, src/evo_user_report.js, src/evo_user_contact_groups.js, src/evo_rest_api.js, src/evo_item_flag.js, src/evo_links.js, src/evo_forms.js, ajax.js */\n' }, nonull: true, // Display missing files - src: ['rsc/js/src/evo_modal_window.js', + src: ['rsc/js/build/evo_generic.bmin.js', + 'rsc/js/src/evo_modal_window.js', 'rsc/js/src/evo_images.js', 'rsc/js/src/evo_user_crop.js', 'rsc/js/src/evo_user_report.js', @@ -288,23 +369,14 @@ module.exports = function(grunt) { 'rsc/js/ajax.js'], dest: 'rsc/js/build/evo_frontoffice.bmin.js' }, - // JS files that are used on front-office standard skins with ddexitpop: - evo_frontoffice_with_ddexitpop: { - options: { - banner: '/* This includes 11 files: src/evo_modal_window.js, src/evo_images.js, src/evo_user_crop.js, src/evo_user_report.js, src/evo_user_contact_groups.js, src/evo_rest_api.js, src/evo_item_flag.js, src/evo_links.js, src/evo_forms.js, ajax.js, src/ddexitpop.js */\n' - }, - nonull: true, // Display missing files - src: ['rsc/js/build/evo_frontoffice.bmin.js', - 'rsc/js/src/ddexitpop.js'], - dest: 'rsc/js/build/evo_frontoffice-with-ddexitpop.bmin.js' - }, // JS files that are used on front-office bootstrap skins: evo_frontoffice_bootstrap: { options: { - banner: '/* This includes 10 files: src/bootstrap-evo_modal_window.js, src/evo_images.js, src/evo_user_crop.js, src/evo_user_report.js, src/evo_user_contact_groups.js, src/evo_rest_api.js, src/evo_item_flag.js, src/evo_links.js, src/evo_forms.js, ajax.js */\n' + banner: '/* This includes 11 files: build/evo_generic.bmin.js, src/bootstrap-evo_modal_window.js, src/evo_images.js, src/evo_user_crop.js, src/evo_user_report.js, src/evo_user_contact_groups.js, src/evo_rest_api.js, src/evo_item_flag.js, src/evo_links.js, src/evo_forms.js, ajax.js */\n' }, nonull: true, // Display missing files - src: ['rsc/js/src/bootstrap-evo_modal_window.js', + src: ['rsc/js/build/evo_generic.bmin.js', + 'rsc/js/src/bootstrap-evo_modal_window.js', 'rsc/js/src/evo_images.js', 'rsc/js/src/evo_user_crop.js', 'rsc/js/src/evo_user_report.js', @@ -316,25 +388,31 @@ module.exports = function(grunt) { 'rsc/js/ajax.js'], dest: 'rsc/js/build/bootstrap-evo_frontoffice.bmin.js' }, - // JS files that are used on front-office bootstrap skins with ddexitpop: - evo_frontoffice_bootstrap_with_ddexitpop: { + // JS files(bundled with jQuery and Bootstrap) that are used on front-office bootstrap skins: + evo_frontoffice_bootstrap_superbundle: { options: { - banner: '/* This includes 11 files: src/bootstrap-evo_modal_window.js, src/evo_images.js, src/evo_user_crop.js, src/evo_user_report.js, src/evo_user_contact_groups.js, src/evo_rest_api.js, src/evo_item_flag.js, src/evo_links.js, src/evo_forms.js, ajax.js, src/ddexitpop.js */\n' + banner: '/* Includes files for bootstrap front-office skins */\n' }, nonull: true, // Display missing files - src: ['rsc/js/build/bootstrap-evo_frontoffice.bmin.js', - 'rsc/js/src/ddexitpop.js'], - dest: 'rsc/js/build/bootstrap-evo_frontoffice-with-ddexitpop.bmin.js' + src: [ + 'rsc/ext/jquery/jquery.min.js', + 'rsc/ext/jquery/jquery-migrate.min.js', + 'rsc/ext/jquery/ui/js/jquery.ui.b2evo.min.js', + 'rsc/ext/bootstrap/js/bootstrap.min.js', + 'rsc/js/build/bootstrap-evo_frontoffice.bmin.js', + ], + dest: 'rsc/js/build/bootstrap-evo_frontoffice-superbundle.bmin.js' }, // JS files that are used on back-office standard skins: evo_backoffice: { options: { - banner: '/* This includes 22 files: functions.js, ajax.js, communication.js, form_extensions.js, extracats.js, dynamic_select.js, backoffice.js, blog_widgets.js,'+ + banner: '/* This includes 23 files: build/evo_generic.bmin.js, functions.js, ajax.js, communication.js, form_extensions.js, extracats.js, dynamic_select.js, backoffice.js, blog_widgets.js,'+ 'src/evo_modal_window.js, src/evo_images.js, src/evo_user_crop.js, src/evo_user_report.js, src/evo_user_deldata.js, '+ 'src/evo_user_org.js, src/evo_automation.js, src/evo_user_tags.js, src/evo_user_status.js, src/evo_user_groups.js, src/evo_rest_api.js, src/evo_links.js, src/evo_forms.js, src/evo_input_counter.js */\n' }, nonull: true, // Display missing files - src: ['rsc/js/functions.js', + src: ['rsc/js/build/evo_generic.bmin.js', + 'rsc/js/functions.js', 'rsc/js/ajax.js', 'rsc/js/communication.js', 'rsc/js/form_extensions.js', @@ -354,6 +432,7 @@ module.exports = function(grunt) { 'rsc/js/src/evo_user_groups.js', 'rsc/js/src/evo_user_filters.js', 'rsc/js/src/evo_rest_api.js', + 'rsc/js/src/evo_files.js', 'rsc/js/src/evo_links.js', 'rsc/js/src/evo_forms.js', 'rsc/js/src/evo_input_counter.js'], @@ -362,12 +441,13 @@ module.exports = function(grunt) { // JS files that are used on back-office bootstrap skins: evo_backoffice_bootstrap: { options: { - banner: '/* This includes 22 files: functions.js, ajax.js, communication.js, form_extensions.js, extracats.js, dynamic_select.js, backoffice.js, '+ + banner: '/* This includes 23 files: build/evo_generic.bmin.js, functions.js, ajax.js, communication.js, form_extensions.js, extracats.js, dynamic_select.js, backoffice.js, '+ 'blog_widgets.js, src/bootstrap-evo_modal_window.js, src/evo_images.js, src/evo_user_crop.js, src/evo_user_report.js, src/evo_user_deldata.js, '+ 'src/evo_user_org.js, src/evo_automation.js, src/evo_user_tags.js, src/evo_user_status.js, src/evo_user_groups.js, src/evo_rest_api.js, src/evo_links.js, src/evo_forms.js, src/evo_input_counter.js */\n' }, nonull: true, // Display missing files - src: ['rsc/js/functions.js', + src: ['rsc/js/build/evo_generic.bmin.js', + 'rsc/js/functions.js', 'rsc/js/ajax.js', 'rsc/js/communication.js', 'rsc/js/form_extensions.js', @@ -387,6 +467,7 @@ module.exports = function(grunt) { 'rsc/js/src/evo_user_groups.js', 'rsc/js/src/evo_user_filters.js', 'rsc/js/src/evo_rest_api.js', + 'rsc/js/src/evo_files.js', 'rsc/js/src/evo_links.js', 'rsc/js/src/evo_forms.js', 'rsc/js/src/evo_input_counter.js'], @@ -396,6 +477,48 @@ module.exports = function(grunt) { src: 'rsc/js/evo_helpdesk_widget.js', dest: 'rsc/js/evo_helpdesk_widget.min.js', }, + evo_fileuploader: { + options: { + banner: '/* This file includes ALL files that are used for quick file uploader */\n' + }, + nonull: true, // Display missing files + src: [ + 'rsc/customized/fileuploader/js/fine-uploader.js', + 'rsc/js/src/evo_init_dragdrop_button.js', + 'rsc/js/src/evo_init_attachment_fieldset.js', + ], + dest: 'rsc/js/build/evo_fileuploader.bmin.js' + }, + evo_fileuploader_sortable: { + options: { + banner: '/* This file includes ALL files that are used for quick file uploader with sortable feature for attachments */\n' + }, + nonull: true, // Display missing files + src: [ + 'rsc/js/build/evo_fileuploader.bmin.js', + 'rsc/ext/jquery/sortable/jquery.sortable.min.js', + 'rsc/js/src/evo_init_link_sortable.js', + ], + dest: 'rsc/js/build/evo_fileuploader_sortable.bmin.js' + }, + evo_jqplot: { + options: { + banner: '/* This file includes ALL files that are used for drawing charts using jqplot */\n' + }, + nonull: true, // Display missing files + src: [ + 'rsc/ext/jquery/jqplot/js/jquery.jqplot.min.js', + 'rsc/ext/jquery/jqplot/js/jqplot.barRenderer.min.js', + 'rsc/ext/jquery/jqplot/js/jqplot.canvasAxisTickRenderer.min.js', + 'rsc/ext/jquery/jqplot/js/jqplot.canvasTextRenderer.min.js', + 'rsc/ext/jquery/jqplot/js/jqplot.canvasOverlay.min.js', + 'rsc/ext/jquery/jqplot/js/jqplot.categoryAxisRenderer.min.js', + 'rsc/ext/jquery/jqplot/js/jqplot.donutRenderer.min.js', + 'rsc/ext/jquery/jqplot/js/jqplot.enhancedLegendRenderer.min.js', + 'rsc/ext/jquery/jqplot/js/jqplot.highlighter.min.js', + ], + dest: 'rsc/js/build/evo_jqplot.bmin.js' + } }, // Markdown to HTML diff --git a/_tests/blogs/evocore/param.funcs.simpletest.php b/_tests/blogs/evocore/param.funcs.simpletest.php index d3217b5dec0..c9c1292cfdd 100644 --- a/_tests/blogs/evocore/param.funcs.simpletest.php +++ b/_tests/blogs/evocore/param.funcs.simpletest.php @@ -55,7 +55,7 @@ function tearDown() function test_defaults() { - $this->assertIdentical( param( 'test1' ), '' ); + $this->assertIdentical( param( 'test1', 'raw' ), '' ); $this->assertIdentical( param( 'test1', 'string', NULL ), '' ); // set from first call $this->assertIdentical( param( 'test2', 'string', NULL ), NULL ); diff --git a/_tests/general/security_checks.simpletest.php b/_tests/general/security_checks.simpletest.php index e15ee0d63cf..64ca78fd9f7 100644 --- a/_tests/general/security_checks.simpletest.php +++ b/_tests/general/security_checks.simpletest.php @@ -58,8 +58,7 @@ class SecurityChecksTestCase extends EvoUnitTestCase 'inc/_blog_main.inc.php', 'inc/_main.inc.php', 'inc/locales/_locale.funcs.php', - 'inc/sessions/model/_search_engines.php', - 'inc/widgets/_widgets.funcs.php', + 'inc/sessions/model/_search_engines.json', ); function __construct() diff --git a/bower.json b/bower.json index bb023d4f273..19583624ad6 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "b2evolution", - "version": "7.1.7-stable", + "version": "7.2.5-stable", "description": "Multiblog/CMS + user community + email marketing + social network + everything you need to run and maintain a modern website (PHP/MySQL).", "devDependencies": { "jquery": ">=1.11.1", diff --git a/conf/_advanced.php b/conf/_advanced.php index 39a4b2630d1..c56e4b22ffe 100644 --- a/conf/_advanced.php +++ b/conf/_advanced.php @@ -827,12 +827,53 @@ /** - * Allow parameters in URL without redirect to Item canonical URL when collection setting "301 redirect to canonical URL when possible" is enabled + * Allow parameters in canonical URLs + * These params will NOT trigger a "301 redirect to canonical" even if the checkboxes for such redirects are enabled + * This applies to ANY canonical URLs (Items but ALSO: Collection, Category, disp=posts, Archive, Tag, User profile) canonical URLs + * + * NOTE: For Item URL we automatically include enabled switchable params of the Item (see "Switchable content" on https://b2evolution.net/man/post-advanced-properties-panel) */ -$noredir_params = array( - 'page', // For showing a different page in a multipage post - 'quote_post', // For quoting a post in the forums - 'quote_comment', // For quoting a comment in the forums +$accepted_in_canonicals__params = array( + 'get_redirected_debuginfo_from_sess_ID', // For display debug info of redirected page from different domain +); +// For pages depending on $disp: +$accepted_in_canonicals_disp__params = array( + 'single' => array( + 'page', // For showing a different page in a multipage post + 'quote_post', // For quoting a post in the forums + 'quote_comment', // For quoting a comment in the forums + ), + 'page' => array( + 'page', // For showing a different page in a multipage post + 'quote_post', // For quoting a post in the forums + 'quote_comment', // For quoting a comment in the forums + ), + 'posts' => array( + 'paged', // For switching between pages of posts + ), + 'flagged' => array( + 'paged', + ), + 'mustread' => array( + 'paged', + ), + 'users' => array( + 'filter_query', + 'results_u_order', + 'u_paged', + ), +); + + +/** + * Pass through the following params in ANY redirect. + * If these params exist, we include them in ANY redirect we make. + * We also do NOT overwrite them (e-g: in case of tiny slugs) + */ +$passthru_in_all_redirs__params = array( + 'utm_source', + 'utm_campaign', + 'utm_medium', ); @@ -913,44 +954,67 @@ * The first string is the production (minified URL), the second is the development URL (optional). */ $library_local_urls = array( - '#jquery#' => array( 'jquery.min.js', 'jquery.js' ), - '#jquery_migrate#' => array( 'jquery/jquery-migrate.min.js', 'jquery/jquery-migrate.js' ), - '#jqueryUI#' => array( 'jquery/jquery.ui.b2evo.min.js', 'jquery/jquery.ui.b2evo.js' ), - '#jqueryUI_css#' => array( 'jquery/smoothness/jquery-ui.b2evo.min.css', 'jquery/smoothness/jquery-ui.b2evo.css' ), + '#jquery#' => array( 'ext:jquery/jquery.min.js', 'ext:jquery/jquery.js' ), + '#jquery_migrate#' => array( 'ext:jquery/jquery-migrate.min.js', 'ext:jquery/jquery-migrate.js' ), + '#jqueryUI#' => array( 'ext:jquery/ui/js/jquery.ui.b2evo.min.js', 'ext:jquery/ui/js/jquery.ui.b2evo.js' ), + '#jqueryUI_css#' => array( 'ext:jquery/ui/css/smoothness/jquery-ui.b2evo.min.css', 'ext:jquery/ui/css/smoothness/jquery-ui.b2evo.css' ), # Uncomment the following lines if your plugins need more jQueryUI features than the ones loaded by b2evo: -# '#jqueryUI#' => array( 'jquery/jquery.ui.all.min.js', 'jquery/jquery.ui.all.js' ), -# '#jqueryUI_css#' => array( 'jquery/smoothness/jquery-ui.min.css', 'jquery/smoothness/jquery-ui.css' ), - '#bootstrap#' => array( 'bootstrap/bootstrap.min.js', 'bootstrap/bootstrap.js' ), - '#bootstrap_css#' => array( 'bootstrap/bootstrap.min.css', 'bootstrap/bootstrap.css' ), - '#bootstrap_theme_css#' => array( 'bootstrap/bootstrap-theme.min.css', 'bootstrap/bootstrap-theme.css' ), - '#bootstrap_typeahead#' => array( 'bootstrap/typeahead.bundle.min.js', 'bootstrap/typeahead.bundle.js' ), - '#easypiechart#' => array( 'jquery/jquery.easy-pie-chart.min.js', 'jquery/jquery.easy-pie-chart.js' ), - '#scrollto#' => array( 'jquery/jquery.scrollto.min.js', 'jquery/jquery.scrollto.js' ), - '#touchswipe#' => array( 'jquery/jquery.touchswipe.min.js', 'jquery/jquery.touchswipe.js' ), - '#jqplot#' => array( 'jquery/jqplot/jquery.jqplot.min.js', 'jquery/jqplot/jquery.jqplot.js' ), - '#jqplot_barRenderer#' => array( 'jquery/jqplot/jqplot.barRenderer.min.js', 'jquery/jqplot/jqplot.barRenderer.js' ), - '#jqplot_canvasAxisTickRenderer#' => array( 'jquery/jqplot/jqplot.canvasAxisTickRenderer.min.js', 'jquery/jqplot/jqplot.canvasAxisTickRenderer.js' ), - '#jqplot_canvasTextRenderer#' => array( 'jquery/jqplot/jqplot.canvasTextRenderer.min.js', 'jquery/jqplot/jqplot.canvasTextRenderer.js' ), - '#jqplot_categoryAxisRenderer#' => array( 'jquery/jqplot/jqplot.categoryAxisRenderer.min.js', 'jquery/jqplot/jqplot.categoryAxisRenderer.js' ), - '#jqplot_enhancedLegendRenderer#' => array( 'jquery/jqplot/jqplot.enhancedLegendRenderer.min.js', 'jquery/jqplot/jqplot.enhancedLegendRenderer.js' ), - '#jqplot_highlighter#' => array( 'jquery/jqplot/jqplot.highlighter.min.js', 'jquery/jqplot/jqplot.highlighter.js' ), - '#jqplot_canvasOverlay#' => array( 'jquery/jqplot/jqplot.canvasOverlay.min.js', 'jquery/jqplot/jqplot.canvasOverlay.js' ), - '#jqplot_donutRenderer#' => array( 'jquery/jqplot/jqplot.donutRenderer.min.js', 'jquery/jqplot/jqplot.donutRenderer.js' ), - '#jqplot_css#' => array( 'jquery/jquery.jqplot.min.css', 'jquery/jquery.jqplot.css' ), - '#tinymce#' => array( 'tiny_mce/tinymce.min.js' ), - '#tinymce_jquery#' => array( 'tiny_mce/jquery.tinymce.min.js' ), - '#flowplayer#' => array( 'flowplayer/flowplayer.min.js', 'flowplayer/flowplayer.js' ), - '#mediaelement#' => array( 'mediaelement/mediaelement-and-player.min.js', 'mediaelement/mediaelement-and-player.js' ), - '#mediaelement_css#' => array( 'mediaelement/mediaelementplayer.min.css', 'mediaelement/mediaelementplayer.css' ), - '#videojs#' => array( 'videojs/video.min.js', 'videojs/video.js' ), - '#videojs_css#' => array( 'videojs/video-js.min.css', 'videojs/video-js.css' ), - '#jcrop#' => array( 'jquery/jquery.jcrop.min.js', 'jquery/jquery.jcrop.js' ), - '#jcrop_css#' => array( 'jquery/jcrop/jquery.jcrop.min.css', 'jquery/jcrop/jquery.jcrop.css' ), - '#fontawesome#' => array( 'font-awesome.min.css', 'font-awesome.css' ), - '#clipboardjs#' => array( 'clipboardjs/clipboard.min.js' ), - '#hotkeys#' => array( 'hotkeys/hotkeys.min.js' ), +# '#jqueryUI#' => array( 'ext:jquery/ui/js/jquery.ui.all.min.js', 'ext:jquery/ui/js/jquery.ui.all.js' ), +# '#jqueryUI_css#' => array( 'ext:jquery/ui/css/smoothness/jquery-ui.min.css', 'ext:jquery/ui/css/smoothness/jquery-ui.css' ), + '#bootstrap#' => array( 'ext:bootstrap/js/bootstrap.min.js', 'ext:bootstrap/js/bootstrap.js' ), + '#bootstrap_css#' => array( 'ext:bootstrap/css/bootstrap.min.css', 'ext:bootstrap/css/bootstrap.css' ), + '#bootstrap_theme_css#' => array( 'ext:bootstrap/css/bootstrap-theme.min.css', 'ext:bootstrap/css/bootstrap-theme.css' ), + '#bootstrap_typeahead#' => array( 'ext:bootstrap/js/typeahead.bundle.min.js', 'ext:bootstrap/js/typeahead.bundle.js' ), + '#easypiechart#' => array( 'ext:jquery/easy-pie-chart/js/jquery.easy-pie-chart.min.js', 'ext:jquery/easy-pie-chart/js/jquery.easy-pie-chart.js' ), + '#scrollto#' => array( 'customized:jquery/scrollto/jquery.scrollto.min.js', 'customized:jquery/scrollto/jquery.scrollto.js' ), + '#touchswipe#' => array( 'ext:jquery/touchswipe/jquery.touchswipe.min.js', 'ext:jquery/touchswipe/jquery.touchswipe.js' ), + '#jqplot#' => array( 'ext:jquery/jqplot/js/jquery.jqplot.min.js' ), + '#jqplot_barRenderer#' => array( 'ext:jquery/jqplot/js/jqplot.barRenderer.min.js' ), + '#jqplot_canvasAxisTickRenderer#' => array( 'ext:jquery/jqplot/js/jqplot.canvasAxisTickRenderer.min.js' ), + '#jqplot_canvasTextRenderer#' => array( 'ext:jquery/jqplot/js/jqplot.canvasTextRenderer.min.js' ), + '#jqplot_categoryAxisRenderer#' => array( 'ext:jquery/jqplot/js/jqplot.categoryAxisRenderer.min.js' ), + '#jqplot_enhancedLegendRenderer#' => array( 'ext:jquery/jqplot/js/jqplot.enhancedLegendRenderer.min.js' ), + '#jqplot_highlighter#' => array( 'ext:jquery/jqplot/js/jqplot.highlighter.min.js' ), + '#jqplot_canvasOverlay#' => array( 'ext:jquery/jqplot/js/jqplot.canvasOverlay.min.js' ), + '#jqplot_donutRenderer#' => array( 'ext:jquery/jqplot/js/jqplot.donutRenderer.min.js' ), + '#jqplot_css#' => array( 'ext:jquery/jqplot/css/jquery.jqplot.min.css', 'ext:jquery/jqplot/css/jquery.jqplot.css' ), + '#tinymce#' => array( 'ext:tiny_mce/tinymce.min.js' ), + '#tinymce_jquery#' => array( 'ext:tiny_mce/jquery.tinymce.min.js' ), + '#flowplayer#' => array( 'ext:flowplayer/flowplayer.min.js', 'ext:flowplayer/flowplayer.js' ), + '#mediaelement#' => array( 'ext:mediaelement/js/mediaelement-and-player.min.js', 'ext:mediaelement/js/mediaelement-and-player.js' ), + '#mediaelement_css#' => array( 'ext:mediaelement/css/mediaelementplayer.min.css', 'ext:mediaelement/css/mediaelementplayer.css' ), + '#videojs#' => array( 'ext:videojs/js/video.min.js', 'ext:videojs/js/video.js' ), + '#videojs_css#' => array( 'ext:videojs/css/video-js.min.css', 'ext:videojs/css/video-js.css' ), + '#jcrop#' => array( 'ext:jquery/jcrop/js/jquery.jcrop.min.js', 'ext:jquery/jcrop/js/jquery.jcrop.js' ), + '#jcrop_css#' => array( 'ext:jquery/jcrop/css/jquery.jcrop.min.css', 'ext:jquery/jcrop/css/jquery.jcrop.css' ), + '#fontawesome#' => array( 'ext:font-awesome/css/font-awesome.min.css', 'ext:font-awesome/css/font-awesome.css' ), + '#clipboardjs#' => array( 'ext:clipboardjs/clipboard.min.js' ), + '#hotkeys#' => array( 'ext:hotkeys/hotkeys.min.js' ), ); +/** + * JS/CSS files which contain other JS/CSS files in order to don't required them twice when main file is required on current page + * + * Key - Alias or relative path of main JS/CSS file, Value - array of bundled files inside the main JS/CSS file + */ +$bundled_files = array( + 'build/bootstrap-evo_frontoffice-superbundle.bmin.js' => array( + '#jquery#', + '#jquery_migrate#', + '#jqueryUI#', + '#bootstrap#', + ), + 'bootstrap-b2evo_base-superbundle.bundle.css' => array( + '#fontawesome#', + '#bootstrap_css#', + 'bootstrap-b2evo_base.bundle.css', + ), + 'bootstrap-b2evo_base-superbundle.bmin.css' => array( + '#fontawesome#', + '#bootstrap_css#', + 'bootstrap-b2evo_base.bmin.css', + ), +); /** * Allow to send outbound pings on localhost @@ -991,6 +1055,40 @@ $access_control_allow_origin = false; // set to '*' or to specific URL to enable CORS requests +/** + * Allow to use a "defer" way for loading of JavaScript files + * + * TODO: Implement new value 'front' in order to allow this only on front-office + */ +$use_defer = true; + +$use_defer_for_backoffice = false; +$use_defer_for_loggedin_users = true; +$use_defer_for_anonymous_users = true; + +$use_defer_for_default_register_form = true; + +$use_defer_for_anonymous_disp_register = true; +$use_defer_for_anonymous_disp_register_finish = true; +$use_defer_for_anonymous_disp_users = true; +$use_defer_for_anonymous_disp_anonpost = true; + +$use_defer_for_loggedin_disp_single_page = true; +$use_defer_for_loggedin_disp_front = true; +$use_defer_for_loggedin_disp_messages = true; +$use_defer_for_loggedin_disp_threads = true; +$use_defer_for_loggedin_disp_profile = true; +$use_defer_for_loggedin_disp_pwdchange = true; +$use_defer_for_loggedin_disp_edit = true; +$use_defer_for_loggedin_disp_proposechange = true; +$use_defer_for_loggedin_disp_edit_comment = true; +$use_defer_for_loggedin_disp_comments = true; +$use_defer_for_loggedin_disp_visits = true; +$use_defer_for_loggedin_disp_contacts = true; + +$disable_tinymce_for_frontoffice_comment_form = false; // Disables TinyMCE plugin in the front-office for comment forms + + // ----- CHANGE THE FOLLOWING SETTINGS ONLY IF YOU KNOW WHAT YOU'RE DOING! ----- $evonetsrv_protocol = 'http'; $evonetsrv_host = 'rpc.b2evo.net'; @@ -1014,4 +1112,4 @@ // This is for plugins to add CS files to the TinyMCE editor window: $tinymce_content_css = array(); -?> \ No newline at end of file +?> diff --git a/conf/_application.php b/conf/_application.php index 5219ec9844d..344551c1fac 100644 --- a/conf/_application.php +++ b/conf/_application.php @@ -15,13 +15,13 @@ * Note: This has to be compatible with {@link http://us2.php.net/en/version-compare}. * @global string */ -$app_version = '7.1.7-stable'; +$app_version = '7.2.5-stable'; /** * Release date (ISO) * @global string */ -$app_date = '2020-12-01'; +$app_date = '2022-08-06'; /** * Is this b2evolution PRO? @@ -44,7 +44,7 @@ * * {@internal Before changing this in CVS, it should be discussed! }} */ -$new_db_version = 16013; +$new_db_version = 16170; /** * Minimum PHP version required for b2evolution to function properly. It will contain each module own minimum PHP version as well. diff --git a/conf/_icons.php b/conf/_icons.php index 79dedadef60..7884808892b 100644 --- a/conf/_icons.php +++ b/conf/_icons.php @@ -269,7 +269,7 @@ function get_icon_info( $name ) 'size-glyph' => array( 10 ), 'fa' => 'caret-right', 'toggle-fa' => 'caret-down', - 'size-fa' => array( 3 ) + 'size-fa' => array( 8 ) ); case 'collapse': return array( 'alt' => '-', @@ -281,7 +281,7 @@ function get_icon_info( $name ) 'size-glyph' => array( 10 ), 'fa' => 'caret-down', 'toggle-fa' => 'caret-right', - 'size-fa' => array( 3 ) + 'size-fa' => array( 8 ) ); case 'filters_show': return array( diff --git a/cron/cron_exec.php b/cron/cron_exec.php index f7938d1480c..1e27490a333 100644 --- a/cron/cron_exec.php +++ b/cron/cron_exec.php @@ -306,11 +306,14 @@ if( ! $is_cli && ! is_admin_page() ) -{ // This is a web request: +{ // This is a web request: echo '

Refresh Now!

'; echo '

This page should refresh automatically in 15 seconds...

'; echo ''; echo ''; + + // Add JavaScript and CSS files included by plugins and skin + include_footerlines(); ?> @@ -319,4 +322,4 @@ // Stop timer of cron job: $Timer->stop( 'cron_exec' ); -?> \ No newline at end of file +?> diff --git a/customize.php b/customize.php index 1082a6b2b0a..df50e13c7fc 100644 --- a/customize.php +++ b/customize.php @@ -64,8 +64,8 @@ { // If view is not defined try to get it from user settings per collection or set default: $view = $UserSettings->get( 'customizer_view_'.$blog ); if( empty( $view ) ) - { // Display collection skin settings by default: - $view = 'coll_skin'; + { // Display collection widget settings by default: + $view = 'coll_widgets'; } memorize_param( 'view', 'string', '', $view ); } @@ -112,12 +112,10 @@ add_js_headline( 'var customizer_url = "'.get_customizer_url().'";' .'var evo_js_lang_not_controlled_page = \''.TS_('This page is not controlled by b2evolution.').'\'' ); -require_css( 'bootstrap-b2evo_base.bmin.css' ); -require_js( '#jquery#' ); -require_js( 'src/evo_customizer.js' ); -require_js( '#bootstrap#' ); -require_css( '#bootstrap_css#' ); -require_js( 'build/bootstrap-evo_frontoffice.bmin.js' ); +require_css( 'bootstrap-b2evo_base.bmin.css', 'blog' ); +require_js_defer( 'build/bootstrap-evo_frontoffice-superbundle.bmin.js', 'blog' ); +require_js_defer( 'src/evo_customizer.js', 'blog' ); +require_css( '#bootstrap_css#', 'blog' ); // Initialize shortcut keys: init_hotkeys_js( 'blog' ); @@ -130,7 +128,6 @@ - @@ -147,7 +144,7 @@ ?>
- +
@@ -156,6 +153,7 @@
+ stop( 'customize.php' ); diff --git a/default.php b/default.php index 3ebf5da3a02..f50af2070b7 100644 --- a/default.php +++ b/default.php @@ -46,8 +46,8 @@ { // Cache miss, we have to generate: // --------------------- PAGE LEVEL CACHING SUPPORT --------------------- -require_js( '#jquery#' ); -require_js( '#bootstrap#' ); +require_js_defer( '#jquery#' ); +require_js_defer( '#bootstrap#' ); require_css( '#bootstrap_css#' ); require_css( 'bootstrap-b2evo_base.bmin.css' ); require_css( 'b2evo_helper_screens.min.css' ); @@ -64,7 +64,6 @@ - @@ -126,7 +125,7 @@ echo '

'.T_('You haven\'t set a default collection yet. Thus, you see this default page.').'

'; - if( is_logged_in() && $current_User->check_perm( 'blogs', 'create' ) ) + if( check_user_perm( 'blogs', 'create' ) ) { // Display this link only for users who can create blog ?> @@ -159,7 +158,7 @@ check_perm( 'blogs', 'create' ) ) + if( check_user_perm( 'blogs', 'create' ) ) { // Display this link only for users who can create blog echo ''; } @@ -178,6 +177,7 @@
+ end_collect(); } // --------------------- PAGE LEVEL CACHING SUPPORT --------------------- -?> \ No newline at end of file +?> diff --git a/evoadm.php b/evoadm.php index 7247b434615..57ab54adbfd 100644 --- a/evoadm.php +++ b/evoadm.php @@ -38,7 +38,7 @@ // Check global permission: -if( ! $current_User->check_perm( 'admin', 'restricted' ) ) +if( ! check_user_perm( 'admin', 'restricted' ) ) { // No permission to access admin... // asimo> This should always denied access, but we insert a hack to create a temporary solution // We do allow comments and items actions, if the redirect is set to the front office! This way users without admin access may use the comments, and items controls. @@ -55,9 +55,9 @@ } // Check user email is validated to make sure users can never has access to admin without a validated email address -if( !$current_User->check_status( 'can_access_admin' ) ) +if( ! check_user_status( 'can_access_admin' ) ) { - if( $current_User->check_status( 'can_be_validated' ) ) + if( check_user_status( 'can_be_validated' ) ) { // redirect back to the login page $action = 'req_activate_email'; require $htsrv_path.'login.php'; diff --git a/htsrv/anon_async.php b/htsrv/anon_async.php index 8469a8adbab..9f68ccbeca9 100644 --- a/htsrv/anon_async.php +++ b/htsrv/anon_async.php @@ -203,7 +203,7 @@ if( strpos( $_SERVER["HTTP_REFERER"], $admin_url ) !== false ) { // If ajax is requested from admin page we should to set a variable $is_admin_page = true if user has permissions // Check global permission: - if( empty($current_User) || ! $current_User->check_perm( 'admin', 'restricted' ) ) + if( ! check_user_perm( 'admin', 'restricted' ) ) { // No permission to access admin... require $adminskins_path.'_access_denied.main.php'; } @@ -226,10 +226,9 @@ ajax_log_add( 'User: #'.$user_ID.' '.$User->login ); - if( is_logged_in() && + if( check_user_perm( 'admin', 'restricted' ) && ( $current_User->ID == $User->ID || $current_User->can_moderate_user( $User->ID ) ) && - $current_User->check_status( 'can_access_admin' ) && - $current_User->check_perm( 'admin', 'restricted' ) ) + check_user_status( 'can_access_admin' ) ) { // Display the moderation buttons only if current user has a permission: $moderation_buttons = '

'; if( ! is_admin_page() ) @@ -237,7 +236,7 @@ $moderation_buttons .= '' .T_('Edit in Back-Office').''; } - if( $current_User->ID != $User->ID && $current_User->check_perm( 'users', 'edit' ) ) + if( $current_User->ID != $User->ID && check_user_perm( 'users', 'edit' ) ) { // Display a button to delete a spammer only for other users and if current user can edit them: $moderation_buttons .= '' @@ -286,7 +285,7 @@ echo get_avatar_imgtag( $User->login, 'login', true, $avatar_size, 'avatar_above_login', '', $avatar_overlay_text, $link_class, true, '' ); echo ''; - if( ! ( $Settings->get( 'allow_anonymous_user_profiles' ) || ( is_logged_in() && $current_User->check_perm( 'user', 'view', false, $User ) ) ) ) + if( ! ( $Settings->get( 'allow_anonymous_user_profiles' ) || ( check_user_perm( 'user', 'view', false, $User ) ) ) ) { // User is not logged in and anonymous users may NOT view user profiles, or if current User has no permission to view additional information about the User echo $moderation_buttons; echo ''; /* end of:

*/ @@ -434,7 +433,7 @@ } // Check permission for spam voting - $current_User->check_perm( 'blog_vote_spam_comments', 'edit', true, $blog_ID ); + check_user_perm( 'blog_vote_spam_comments', 'edit', true, $blog_ID ); $type = param( 'type', 'string' ); $commentid = param( 'commentid', 'integer' ); @@ -1045,7 +1044,7 @@ if( $edited_Comment !== false ) { // The comment still exists // Check permission: - $current_User->check_perm( 'comment!'.$status, 'moderate', true, $edited_Comment ); + check_user_perm( 'comment!'.$status, 'moderate', true, $edited_Comment ); $redirect_to = param( 'redirect_to', 'url', NULL ); @@ -1178,7 +1177,7 @@ } // Check permission: - $current_User->check_perm( 'orgs', 'edit', true, $user_Organization ); + check_user_perm( 'orgs', 'edit', true, $user_Organization ); // Use the glyph or font-awesome icons if it is defined by skin param( 'b2evo_icons_type', 'string', '' ); @@ -1324,7 +1323,7 @@ $Session->assert_received_crumb( 'user' ); $user_ID = param( 'user_ID', 'integer', true ); - if( ! is_logged_in() || ( isset( $User ) && $current_User->ID == $User->ID ) || ! $current_User->check_status( 'can_report_user', $user_ID ) ) + if( ! is_logged_in() || ( isset( $User ) && $current_User->ID == $User->ID ) || ! check_user_status( 'can_report_user', $user_ID ) ) { // Only if current user can reports break; } @@ -1363,8 +1362,8 @@ $Session->assert_received_crumb( 'user' ); if( ! is_logged_in() || ( isset( $User ) && $current_User->ID == $User->ID ) || - ! $current_User->check_perm( 'perm_messaging', 'reply' ) || - ! $current_User->check_status( 'can_edit_contacts' ) ) + ! check_user_perm( 'perm_messaging', 'reply' ) || + ! check_user_status( 'can_edit_contacts' ) ) { // Only if current user can reports break; } @@ -1499,9 +1498,11 @@ // Default values: $image_caption = NULL; + $image_disable_caption = false; + $image_alt = NULL; + $image_disable_alt = false; $image_href = NULL; $image_class = NULL; - $image_disable_caption = false; $thumbnail_href = NULL; $thumbnail_size = 'medium'; $thumbnail_alignment = 'left'; @@ -1542,10 +1543,22 @@ } $opt_index++; } - // TODO: Alt text: + $href_regexp = '#^(https?|\(\((.*?)\)\))$#i'; + // Alt text: + $image_disable_alt = ( isset( $parts[ $opt_index ] ) && $parts[ $opt_index ] == '-' ); + if( isset( $parts[ $opt_index ] ) && + substr( $parts[ $opt_index ], 0, 1 ) != '.' && + ! preg_match( $href_regexp, $parts[ $opt_index ] ) ) + { + if( $parts[ $opt_index ] != '-' ) + { + $image_alt = $parts[ $opt_index ]; + } + $opt_index++; + } // HRef: if( ! empty( $parts[ $opt_index ] ) && - preg_match( '#^(https?|\(\((.*?)\)\))$#i', $parts[ $opt_index ], $href_match ) ) + preg_match( $href_regexp, $parts[ $opt_index ], $href_match ) ) { if( stripos( $href_match[0], 'http' ) === 0 ) { // Absolute URL: @@ -1567,10 +1580,23 @@ break; case 'thumbnail': - // TODO: Alt text: + $href_regexp = '#^(https?|\(\((.*?)\)\))$#i'; + // Alt text: + $image_disable_alt = ( isset( $parts[ $opt_index ] ) && $parts[ $opt_index ] == '-' ); + if( isset( $parts[ $opt_index ] ) && + substr( $parts[ $opt_index ], 0, 1 ) != '.' && + ! preg_match( $href_regexp, $parts[ $opt_index ] ) && + ! in_array( $parts[ $opt_index ], array( 'small', 'medium', 'large', 'left', 'right' ) ) ) + { + if( $parts[ $opt_index ] != '-' ) + { + $image_alt = $parts[ $opt_index ]; + } + $opt_index++; + } // HRef: if( ! empty( $parts[ $opt_index ] ) && - preg_match( '#^(https?|\(\((.*?)\)\))$#i', $parts[ $opt_index ], $href_match ) ) + preg_match( $href_regexp, $parts[ $opt_index ], $href_match ) ) { if( stripos( $href_match[0], 'http' ) === 0 ) { // Absolute URL: @@ -1606,9 +1632,22 @@ break; case 'inline': - if( isset( $parts[2] ) ) + // Alt text: + $image_disable_alt = ( isset( $parts[ $opt_index ] ) && $parts[ $opt_index ] == '-' ); + if( isset( $parts[ $opt_index ] ) && + substr( $parts[ $opt_index ], 0, 1 ) != '.' && + ! in_array( $parts[ $opt_index ], array( 'small', 'medium', 'large', 'original' ) ) ) { - $inline_class = $parts[2]; + if( $parts[ $opt_index ] != '-' ) + { + $image_alt = $parts[ $opt_index ]; + } + $opt_index++; + } + // Class: + if( isset( $parts[ $opt_index ] ) ) + { + $inline_class = $parts[ $opt_index ]; } break; @@ -1681,14 +1720,15 @@ // Update last touched date of Owners $LinkOwner->update_last_touched_date(); - if( $link_position == 'cover' && $LinkOwner->type == 'item' ) - { // Position "Cover" can be used only by one link - // Replace previous position with "Inline" + if( $LinkOwner->type == 'item' && + ( $link_position == 'cover' || $link_position == 'background' ) ) + { // Position "Cover" or "Background" can be used only by one link + // Replace previous position with "After more": $DB->query( 'UPDATE T_links SET link_position = "aftermore" WHERE link_ID != '.$DB->quote( $link_ID ).' AND link_itm_ID = '.$DB->quote( $LinkOwner->Item->ID ).' - AND link_position = "cover"' ); + AND link_position = '.$DB->quote( $link_position ) ); } } else @@ -1843,7 +1883,7 @@ $Blog = & $BlogCache->get_by_ID( $blog ); // Check permission: - $current_User->check_perm( 'blog_properties', 'edit', true, $blog ); + check_user_perm( 'blog_properties', 'edit', true, $blog ); // Container code: param( 'container', 'string' ); @@ -1957,7 +1997,7 @@ $Blog = $BlogCache->get_by_ID( $blog ); // Check permission: - $current_User->check_perm( 'blog_properties', 'edit', true, $blog ); + check_user_perm( 'blog_properties', 'edit', true, $blog ); param( 'wi_ID', 'integer' ); @@ -1991,53 +2031,42 @@ $Form->text_input( 'blog_url_alias[]', '', 50, T_('Alias URL'), $alias_field_note, array( 'class' => 'evo_url_alias', 'maxlength' => 255 ) ); break; - case 'get_item_parent_info': + case 'get_item_selector_info': + // Get Item's info after selector from Modal/AJAX window by $Form->item_selector(): + // Check that this action request is not a CSRF hacked request: - $Session->assert_received_crumb( 'item' ); + $Session->assert_received_crumb( 'item_selector' ); // Use the glyph or font-awesome icons if requested by skin param( 'b2evo_icons_type', 'string', 'fontawesome-glyphicons' ); - param( 'parent_ID', 'integer', true ); + param( 'item_ID', 'integer', true ); $ItemCache = & get_ItemCache(); - $parent_Item = & $ItemCache->get_by_ID( $parent_ID, false, false ); - $r = array(); - if( $parent_Item ) + $item_selector_info = array(); + if( $selected_Item = & $ItemCache->get_by_ID( $item_ID, false, false ) ) { if( is_logged_in() ) { // Remember what last collection was used for linking in order to display it by default on next linking: global $UserSettings; - - $UserSettings->set( 'last_select_parent_coll_ID', $parent_Item->get_blog_ID() ); + $UserSettings->set( 'last_selected_item_coll_ID', $selected_Item->get_blog_ID() ); $UserSettings->dbupdate(); } - $parent_info = ''; - $status_icons = get_visibility_statuses( 'icons' ); - if( isset( $status_icons[ $parent_Item->get( 'status' ) ] ) ) - { // Status colored icon: - $parent_info .= $status_icons[ $parent_Item->get( 'status' ) ]; - } - // Title with link to permament url: - $parent_info .= ' '.$parent_Item->get_title( array( 'link_type' => 'permalink' ) ); - // Icon to edit: - $parent_info .= ' '.$parent_Item->get_edit_link( array( 'text' => '#icon#' ) ); - - $r['parent_ID'] = $parent_Item->ID; - $r['parent_info'] = $parent_info; - $r['parent_coll_ID'] = $parent_Item->get_blog_ID(); + $item_selector_info['item_ID'] = $selected_Item->ID; + $item_selector_info['item_info'] = $selected_Item->get_form_selector_info(); + $item_selector_info['coll_ID'] = $selected_Item->get_blog_ID(); } - echo json_encode( $r ); + echo json_encode( $item_selector_info ); break; case 'get_user_default_filters_form': // Get form to change default users list filters: // Check permission: - $current_User->check_perm( 'users', 'edit', true ); + check_user_perm( 'users', 'edit', true ); // Load the AdminUI class for the skin: global $current_User, $UserSettings, $is_admin_page; diff --git a/htsrv/async.php b/htsrv/async.php index 6ae4ad614ad..43e1f468261 100644 --- a/htsrv/async.php +++ b/htsrv/async.php @@ -44,7 +44,7 @@ param( 'action', 'string', '' ); // Check global permission: -if( $action != 'test_api' && ( empty($current_User) || ! $current_User->check_perm( 'admin', 'restricted' ) ) ) +if( $action != 'test_api' && ! check_user_perm( 'admin', 'restricted' ) ) { // No permission to access admin... (Exclude action of API testing in order to make a quick request without logging in) require $adminskins_path.'_access_denied.main.php'; } @@ -101,7 +101,7 @@ // This does not require CSRF because it doesn't update the db, it only displays a new block of empty plugin setting fields // Check permission to view plugin settings: - $current_User->check_perm( 'options', 'view', true ); + check_user_perm( 'options', 'view', true ); // Set admin skin, used for buttons, @see button_class() $admin_skin = $UserSettings->get( 'admin_skin', $current_User->ID ); @@ -194,7 +194,7 @@ $edited_Comment_Item = & $edited_Comment->get_Item(); // Check user permission to edit this internal comment - $current_User->check_perm( 'meta_comment', 'edit', true, $edited_Comment ); + check_user_perm( 'meta_comment', 'edit', true, $edited_Comment ); // Load Blog of the Item $Collection = $Blog = & $edited_Comment_Item->get_Blog(); @@ -313,7 +313,7 @@ if( $edited_Comment !== false ) { // The comment still exists // Check permission: - $current_User->check_perm( 'comment!CURSTATUS', 'delete', true, $edited_Comment ); + check_user_perm( 'comment!CURSTATUS', 'delete', true, $edited_Comment ); $result_success = $edited_Comment->dbdelete(); } @@ -349,7 +349,7 @@ if( $edited_Comment !== false && $edited_Comment->author_url != NULL ) { // The comment still exists // Check permission: - $current_User->check_perm( 'comment!CURSTATUS', 'edit', true, $edited_Comment ); + check_user_perm( 'comment!CURSTATUS', 'edit', true, $edited_Comment ); $edited_Comment->set( 'author_url', NULL ); $edited_Comment->dbupdate(); @@ -379,7 +379,7 @@ $Blog = & $BlogCache->get_by_ID( $blog ); // Check minimum permissions ( The comment specific permissions are checked when displaying the comments ) - $current_User->check_perm( 'blog_ismember', 'view', true, $blog ); + check_user_perm( 'blog_ismember', 'view', true, $blog ); // Set admin skin, used for buttons, @see button_class() $admin_skin = $UserSettings->get( 'admin_skin', $current_User->ID ); @@ -404,7 +404,7 @@ $Session->assert_received_crumb( 'domtype' ); // Check permission: - $current_User->check_perm( 'stats', 'edit', true ); + check_user_perm( 'stats', 'edit', true ); load_funcs('sessions/model/_hitlog.funcs.php'); @@ -424,7 +424,7 @@ $Session->assert_received_crumb( 'domstatus' ); // Check permission: - $current_User->check_perm( 'stats', 'edit', true ); + check_user_perm( 'stats', 'edit', true ); load_funcs('sessions/model/_hitlog.funcs.php'); @@ -444,7 +444,7 @@ $Session->assert_received_crumb( 'iprange' ); // Check permission: - $current_User->check_perm( 'spamblacklist', 'edit', true ); + check_user_perm( 'spamblacklist', 'edit', true ); $new_status = param( 'new_status', 'string' ); $iprange_ID = param( 'iprange_ID', 'integer', true ); @@ -462,7 +462,7 @@ $Session->assert_received_crumb( 'emadrstatus' ); // Check permission: - $current_User->check_perm( 'emails', 'edit', true ); + check_user_perm( 'emails', 'edit', true ); $new_status = param( 'new_status', 'string' ); $emadr_ID = param( 'emadr_ID', 'integer', true ); @@ -503,7 +503,7 @@ $Session->assert_received_crumb( 'grouplevel' ); // Check permission: - $current_User->check_perm( 'users', 'edit', true ); + check_user_perm( 'users', 'edit', true ); $group_level = param( 'new_group_level', 'integer' ); $group_ID = param( 'group_ID', 'integer' ); @@ -524,7 +524,7 @@ $Session->assert_received_crumb( 'country' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); load_funcs( 'regional/model/_regional.funcs.php' ); @@ -556,7 +556,7 @@ $Item = & $ItemCache->get_by_ID( $post_ID ); // Check permission: - $current_User->check_perm( 'item_post!CURSTATUS', 'edit', true, $Item ); + check_user_perm( 'item_post!CURSTATUS', 'edit', true, $Item ); $new_attrs = ''; switch( $field ) @@ -641,7 +641,7 @@ $Item = & $ItemCache->get_by_ID( $post_ID ); // Check permission: - $current_User->check_perm( 'item_post!CURSTATUS', 'edit', true, $Item ); + check_user_perm( 'item_post!CURSTATUS', 'edit', true, $Item ); if( $item_order === '-' || $item_order === '' ) { // Set NULL for these values: @@ -669,7 +669,7 @@ $cat_ID = param( 'cat_ID', 'integer' ); // Check permission: - $current_User->check_perm( 'blog_cats', 'edit', true, $blog ); + check_user_perm( 'blog_cats', 'edit', true, $blog ); if( $cat_order === '-' || $cat_order === '' || intval( $cat_order ) == '' ) { // Set NULL for these values @@ -685,6 +685,38 @@ } break; + case 'item_status_order_edit': + // Update order of a item status from list screen by clicking on the order column + + // Check that this action request is not a CSRF hacked request: + $Session->assert_received_crumb( 'itemstatus' ); + + $item_status_order = param( 'new_item_status_order', 'string' ); + + // Make sure we got an pst_ID: + $item_status_ID = param( 'pst_ID', 'integer', true ); + + // Check permission: + check_user_perm( 'options', 'edit', true ); + + if( $item_status_order === '-' || $item_status_order === '' ) + { // Set NULL for these values: + $item_status_order = NULL; + } + else + { // Make an order to integer: + $item_status_order = intval( $item_status_order ); + } + + $ItemStatusCache = & get_ItemStatusCache(); + if( $edited_ItemStatus = & $ItemStatusCache->get_by_ID( $item_status_ID, false ) ) + { // Update item status order if it exists in DB + $edited_ItemStatus->set( 'order', ( $item_status_order === '' ? NULL : $item_status_order ), true ); + $edited_ItemStatus->dbupdate(); + echo ''.( $item_status_order === NULL ? '-' : $item_status_order ).''; + } + break; + case 'cat_ityp_ID_edit': // Update default Item Type of a chapter from list screen by clicking on the order column: @@ -696,7 +728,7 @@ $cat_ID = param( 'cat_ID', 'integer' ); // Check permission: - $current_User->check_perm( 'blog_cats', '', true, $blog ); + check_user_perm( 'blog_cats', '', true, $blog ); if( ! empty( $cat_ityp_ID ) ) { // Remove prefix "_" which is used only for correct order in jeditable selector: @@ -747,7 +779,7 @@ $Session->assert_received_crumb( 'itemgoal' ); // Check permission: - $current_User->check_perm( 'blog_post_statuses', 'edit', true, $blog ); + check_user_perm( 'blog_post_statuses', 'edit', true, $blog ); $cat_ID = param( 'cat_id', 'integer', 0 ); @@ -783,7 +815,7 @@ param( 'fileroot_ID', 'string' ); // Check permission: - $current_User->check_perm( 'files', 'add', true, $fileroot_ID ); + check_user_perm( 'files', 'add', true, $fileroot_ID ); param( 'path', 'filepath' ); param( 'oldfile', 'filepath' ); @@ -825,7 +857,7 @@ $Session->assert_received_crumb( 'link' ); // Check permission: - $current_User->check_perm( 'files', 'view' ); + check_user_perm( 'files', 'view' ); param( 'iframe_name', 'string', '' ); param( 'link_owner_type', 'string', true ); @@ -840,12 +872,10 @@ $additional_params .= empty( $path ) ? '' : '&path='.$path; $additional_params .= empty( $fm_highlight ) ? '' : '&fm_highlight='.$fm_highlight; - echo '
' - .'' + echo '' .'' - .'
'; + .' onload="document.getElementById(\'link_attachment_loader\').style.display=\'none\'">loading'; break; @@ -856,7 +886,7 @@ $Session->assert_received_crumb( 'file_attachment' ); // Check permission: - $current_User->check_perm( 'files', 'view' ); + check_user_perm( 'files', 'view' ); param( 'iframe_name', 'string', '' ); param( 'field_name', 'string', '' ); @@ -871,12 +901,10 @@ $additional_params .= empty( $fm_highlight ) ? '' : '&fm_highlight='.$fm_highlight; //$additional_params .= empty( $field_name ) ? '' : '&field_name='.$field_name; - echo '
' - .'' + echo '' .'' - .'
'; + .' onload="document.getElementById(\'link_attachment_loader\').style.display=\'none\'">loading'; break; @@ -890,14 +918,12 @@ $FileRoot = & $FileRootCache->get_by_type_and_ID( 'import', '0', true ); // Check permission: - $current_User->check_perm( 'files', 'view', true, $FileRoot ); + check_user_perm( 'files', 'view', true, $FileRoot ); - echo '
' - .'' + echo '' .'' - .'
'; + .' onload="document.getElementById(\'import_files_loader\').style.display=\'none\'">loading'; break; @@ -913,7 +939,7 @@ $Session->assert_received_crumb( 'users' ); // Check permission: - $current_User->check_perm( 'options', 'view', true ); + check_user_perm( 'options', 'view', true ); param( 'autm_ID', 'integer', true ); param( 'enlt_ID', 'integer', NULL ); @@ -973,7 +999,7 @@ $Session->assert_received_crumb( 'campaign' ); // Check permission: - $current_User->check_perm( 'options', 'view', true ); + check_user_perm( 'options', 'view', true ); param( 'ecmp_ID', 'integer', true ); param( 'skip_tags', 'string', '' ); @@ -1008,7 +1034,7 @@ // Get automation status: // Check permission: - $current_User->check_perm( 'options', 'view', true ); + check_user_perm( 'options', 'view', true ); param( 'autm_ID', 'integer', true ); @@ -1103,6 +1129,192 @@ dbm_delete_itemprecache(); break; + case 'browse_subdirs': + // Load sub-directories for Files Browser: + + // Use the glyph or font-awesome icons if requested by skin + param( 'b2evo_icons_type', 'string', '' ); + + // Path to parent directory with root data: + param( 'path', 'filepath' ); + + if( ! preg_match( '#^([a-z]+)_(\d+):(.+)$#', $path, $path_data ) ) + { // Invalid path: + debug_die( 'Invalid path!' ); + } + + // Try to get File Root by requested path: + $FileRootCache = & get_FileRootCache(); + $dir_FileRoot = & $FileRootCache->get_by_type_and_ID( $path_data[1], $path_data[2] ); + + // Check permission: + check_user_perm( 'files', 'view', true, $dir_FileRoot ); + + $FileCache = & get_FileCache(); + if( ! ( $dir_File = & $FileCache->get_by_root_and_path( $path_data[1], $path_data[2], $path_data[3] ) ) || + ! $dir_File->is_dir() ) + { // Invalid directory: + debug_die( 'Invalid directory!' ); + } + + // Create list to load sub-folders: + load_class( 'files/model/_filelist.class.php', 'Filelist' ); + $dir_Filelist = new Filelist( $dir_FileRoot, trailing_slash( $dir_File->get_full_path() ) ); + check_showparams( $dir_Filelist ); + $dir_Filelist->load(); + $dir_Filelist->sort( 'name' ); + + if( ! $dir_Filelist->count_dirs() ) + { // Wrong requested directory: + debug_die( 'No sub-directories!' ); + } + + // Return sub-directories of the requested directory: + while( $subdir_File = & $dir_Filelist->get_next( 'dir' ) ) + { + echo '
  • '.get_directory_tree( $dir_FileRoot, $subdir_File->get_full_path(), $dir_File->get_full_path(), false, $subdir_File->get_rdfs_rel_path(), true ).'
  • '; + } + break; + + case 'browse_existing_attachments': + + global $DB; + $mode = 'upload'; + + $FileRootCache = & get_FileRootCache(); + + // Get all Item comments: + $link_type = param( 'link_type', 'string', true ); + $link_object_ID = param( 'link_object_ID', 'integer', true ); + + $LinkOwner = get_LinkOwner( $link_type, $link_object_ID ); + $LinkCache = & get_LinkCache(); + + $links = array(); + $link_owner_class = get_class( $LinkOwner->link_Object ); + + load_class( '_core/model/dataobjects/_dataobjectlist2.class.php', 'DataObjectList2' ); + $LinkCache = & get_LinkCache(); + $ea_Linklist = new DataObjectList2( $LinkCache ); + + switch( $link_owner_class ) + { + case 'Item': + case 'Comment': + if( $link_owner_class == 'Comment' ) + { + $edited_Item = $LinkOwner->get_Item(); + } + else + { + $edited_Item = $LinkOwner->Item; + } + $item_ID = $edited_Item->ID; + + // Get list of comment IDs under Item or related to Comment: + $comments_SQL = new SQL( 'Get all the comments of an Item' ); + $comments_SQL->SELECT( 'comment_ID' ); + $comments_SQL->FROM( 'T_comments' ); + $comments_SQL->WHERE( 'comment_item_ID = '.$DB->quote( $item_ID ) ); + if( ! $edited_Item->can_meta_comment() ) + { // If current User doesn't have an access to meta comments: + $comments_SQL->WHERE( 'comment_type != "meta"' ); + } + $comment_IDs = $DB->get_col( $comments_SQL ); + + $links_SQL = new SQL( 'Get all the links belonging to comments of an Item' ); + $links_SQL->SELECT( '*' ); + $links_SQL->FROM( 'T_links AS l' ); + if( $comment_IDs ) + { + $links_SQL->WHERE( 'link_cmt_ID IN ('.$DB->quote( $comment_IDs ).')' ); + } + $links_SQL->WHERE_or( 'link_itm_ID = '.$DB->quote( $item_ID ) ); + $links_SQL->ORDER_BY( 'link_datemodified DESC, link_datecreated DESC' ); + + $ea_Linklist->sql = $links_SQL->get(); + $ea_Linklist->run_query( false, false, false, 'get_attachment_LinkList' ); + + // Get FileRoot and dummy FileList: + if( $ea_Linklist->get_total_rows() ) + { // Use first attachment to get the FileRoot: + $Link = & $ea_Linklist->get_by_idx( 0 ); + $File = & $Link->get_File(); + $fm_FileRoot = & $File->get_FileRoot(); + } + else + { + global $Blog; + + if( empty( $Blog ) ) + { + $Blog = $edited_Item->get_Blog(); + } + + $fm_FileRoot = & $FileRootCache->get_by_type_and_ID( 'collection', $Blog->ID ); + } + load_class( 'files/model/_filelist.class.php', 'FileList' ); + $fm_Filelist = new Filelist( $fm_FileRoot, false ); // Arbitrary list of attached files + $selected_Filelist = new Filelist( $fm_FileRoot, false ); // Arbitrary list of attached files + break; + + case 'EmailCampaign': + if( $edited_Newsletter = & $LinkOwner->link_Object->get_Newsletter() ) + { + // Get list of email campaign IDs under the same Newsletter: + $email_campaigns_SQL = new SQL( 'Get all the email campaigns of a List' ); + $email_campaigns_SQL->SELECT( 'ecmp_ID' ); + $email_campaigns_SQL->FROM( 'T_email__campaign' ); + $email_campaigns_SQL->WHERE( 'ecmp_enlt_ID = '.$DB->quote( $edited_Newsletter->ID ) ); + $email_campaign_IDs = $DB->get_col( $email_campaigns_SQL ); + + if( $email_campaign_IDs ) + { + $links_SQL = new SQL( 'Get all the links belonging to email campaigns of a List' ); + $links_SQL->SELECT( '*' ); + $links_SQL->FROM( 'T_links AS l' ); + $links_SQL->WHERE( 'link_ecmp_ID IN ('.$DB->quote( $email_campaign_IDs ).')' ); + $links_SQL->ORDER_BY( 'link_datemodified DESC, link_datecreated DESC' ); + + $ea_Linklist->sql = $links_SQL->get(); + $ea_Linklist->run_query( false, false, false, 'get_attachment_LinkList' ); + } + } + + // Get FileRoot and dummy FileList: + if( $ea_Linklist->get_total_rows() ) + { // Use first attachment to get the FileRoot: + $Link = & $ea_Linklist->get_by_idx( 0 ); + $File = & $Link->get_File(); + $fm_FileRoot = & $File->get_FileRoot(); + } + else + { + $fm_FileRoot = & $FileRootCache->get_by_type_and_ID( 'emailcampaign', $LinkOwner->link_Object->ID ); + } + load_class( 'files/model/_filelist.class.php', 'FileList' ); + $fm_Filelist = new Filelist( $fm_FileRoot, false ); // Arbitrary list of attached files + $selected_Filelist = new Filelist( $fm_FileRoot, false ); // Arbitrary list of attached files + break; + + default: + debug_die( 'Existing attachments list not available to '.$link_owner_class ); + } + + global $current_User, $UserSettings, $is_admin_page, $adminskins_path; + $admin_skin = $UserSettings->get( 'admin_skin', $current_User->ID ); + $is_admin_page = true; + require_once $adminskins_path.$admin_skin.'/_adminUI.class.php'; + + $AdminUI = new AdminUI(); + $Widget = new Widget( 'file_browser' ); + $Widget->disp_template_replaced( 'block_start' ); + + require $inc_path.'links/views/_link_file_list.inc.php'; + + $Widget->disp_template_raw( 'block_end' ); + break; + default: $incorrect_action = true; break; diff --git a/htsrv/comment_post.php b/htsrv/comment_post.php index 675a9686f44..8fa6b08fa1c 100644 --- a/htsrv/comment_post.php +++ b/htsrv/comment_post.php @@ -627,7 +627,7 @@ $success_message = T_('Your comment is now visible by the members of this section (this collection).'); break; case 'review': - if( is_logged_in() && $current_User->check_perm( 'blog_comment!review', 'create', false, $blog ) ) + if( check_user_perm( 'blog_comment!review', 'create', false, $blog ) ) { $success_message = T_('Your comment is now visible by moderators only (+You).'); break; diff --git a/htsrv/comment_review.php b/htsrv/comment_review.php index d387580aaed..0e1a77087f0 100644 --- a/htsrv/comment_review.php +++ b/htsrv/comment_review.php @@ -28,7 +28,7 @@ { // Display messages and exit // Bootstrap - require_js( '#bootstrap#', 'rsc_url' ); + require_js_defer( '#bootstrap#', 'rsc_url' ); require_css( '#bootstrap_css#', 'rsc_url' ); require_css( 'bootstrap-backoffice-b2evo_base.bmin.css', 'rsc_url' ); @@ -67,6 +67,7 @@
    + spam_karma( ' • '.T_('Spam Karma').': %s%', ' • '.T_('No Spam Karma') ); echo ''; - $user_permission = is_logged_in() && ( $current_User->check_perm( 'meta_comment', 'edit', false, $posted_Comment ) ); + $user_permission = check_user_perm( 'meta_comment', 'edit', false, $posted_Comment ); if( $user_permission ) { // Put the internal comment content into this container to edit by ajax: echo '
    '; @@ -301,7 +302,7 @@ $status_index = get_visibility_statuses( 'ordered-index', array( 'redirected' ) ); // delete button - if( $current_User->check_perm( 'comment!CURSTATUS', 'delete', false, $posted_Comment ) ) + if( check_user_perm( 'comment!CURSTATUS', 'delete', false, $posted_Comment ) ) { echo '
    '; - break; + case 'text': + echo '
    '; + /* + * Text file view: + */ + if( ($buffer = @file( $selected_File->get_full_path() )) !== false ) + { // Display raw file + param( 'showlinenrs', 'integer', 0 ); - case 'text': - echo '
    '; - /* - * Text file view: - */ - if( ($buffer = @file( $selected_File->get_full_path() )) !== false ) - { // Display raw file - param( 'showlinenrs', 'integer', 0 ); + $buffer_lines = count( $buffer ); - $buffer_lines = count( $buffer ); + echo '
    '; - echo '
    '; - - echo '

    '; - echo T_('File').': '.$selected_File->dget('name').''; - echo ' · '; - echo T_('Title').': '.$selected_File->dget( 'title' ).''; - echo '

    '; + echo '

    '; + echo T_('File').': '.$selected_File->dget('name').''; + echo ' · '; + echo T_('Title').': '.$selected_File->dget( 'title' ).''; + echo '

    '; - echo '

    '; - echo T_('Description').': '.$selected_File->dget( 'desc' ); - echo '

    '; + echo '

    '; + echo T_('Description').': '.$selected_File->dget( 'desc' ); + echo '

    '; - if( !$buffer_lines ) - { - echo '

    ** '.T_('Empty file').'! **

    '; - } - else - { - echo '

    '; - printf( T_('%d lines'), $buffer_lines ); + if( !$buffer_lines ) + { + echo '

    ** '.T_('Empty file').'! **

    '; + } + else + { + echo '

    '; + printf( T_('%d lines'), $buffer_lines ); - $linenr_width = strlen( $buffer_lines+1 ); + $linenr_width = strlen( $buffer_lines+1 ); - echo ' ['; - ?> -

    '; + echo ']

    '; + echo '
    '; - echo '
    ';
    +					echo '
    ';
     
    -				for( $i = 0; $i < $buffer_lines; $i++ )
    -				{
    -					echo '';
    -					if( $showlinenrs )
    +					for( $i = 0; $i < $buffer_lines; $i++ )
     					{
    -						echo ' '.str_pad($i+1, $linenr_width, ' ', STR_PAD_LEFT).' ';
    +						echo '';
    +						if( $showlinenrs )
    +						{
    +							echo ' '.str_pad($i+1, $linenr_width, ' ', STR_PAD_LEFT).' ';
    +						}
    +						echo ''.htmlspecialchars( str_replace( "\t", '  ', $buffer[$i] ) );  // TODO: customize tab-width
     					}
    -					echo ''.htmlspecialchars( str_replace( "\t", '  ', $buffer[$i] ) );  // TODO: customize tab-width
    -				}
     
    -	  		echo '
    '; + echo '
    '; - echo '
    ** '.T_('End Of File').' **
    '; + echo '
    ** '.T_('End Of File').' **
    '; + } } - } - else - { - echo '

    '.sprintf( T_('The file «%s» could not be accessed!'), $selected_File->get_rdfs_rel_path( $selected_File ) ).'

    '; - } - echo ''; - break; + else + { + echo '

    '.sprintf( T_('The file «%s» could not be accessed!'), $selected_File->get_rdfs_rel_path( $selected_File ) ).'

    '; + } + echo ''; + break; - default: - echo '

    '.sprintf( T_('The file «%s» could not be accessed!'), $selected_File->dget('name') ).'

    '; - break; -} -?> + default: + echo '

    '.sprintf( T_('The file «%s» could not be accessed!'), $selected_File->dget('name') ).'

    '; + break; + } + // Add JavaScript and CSS files included by plugins and skin + include_footerlines(); +?> - \ No newline at end of file + diff --git a/inc/_blog_main.inc.php b/inc/_blog_main.inc.php index 2e48e5e9c57..179623e4982 100644 --- a/inc/_blog_main.inc.php +++ b/inc/_blog_main.inc.php @@ -318,6 +318,8 @@ { // TAG? Does the pathinfo end with a / or a ; ? $last_len = strlen( $last_part ); + $user_page_prefix = $Blog->get_setting( 'user_prefix' ).':'; + $user_page_prefix_length = strlen( $user_page_prefix ); if( ( $last_char == '-' && ( ! $tags_dash_fix || $last_len != 40 ) ) // In very old b2evo version we had ITEM slugs truncated at 40 and possibly ending with `-` || $last_char == ':' || $last_char == ';' ) @@ -334,6 +336,24 @@ } $disp = 'posts'; } + elseif( $user_page_prefix_length > 1 && + strlen( $path_elements[0] ) > $user_page_prefix_length && + substr( $path_elements[0], 0, $user_page_prefix_length ) == $user_page_prefix ) + { // Alias for disp=user: + $user_ID = -1; // Set -1 for case when user is not detected by login and ID + $user_request = substr( $path_elements[0], $user_page_prefix_length ); + + $UserCache = & get_UserCache(); + if( $User = & $UserCache->get_by_login( $user_request ) || + ( is_number( $user_request ) && $User = & $UserCache->get_by_ID( $user_request, false, false ) ) ) + { // If user is detected in DB by login or ID: + $user_ID = $User->ID; + } + + // Set disp to user with ID of user which was detected from request URL: + $disp = 'user'; + set_param( 'user_ID', $user_ID ); + } elseif( ( $tags_dash_fix && $last_char == '-' && $last_len == 40 ) || $last_char != '/' ) { // NO ENDING SLASH or ends with a dash, is 40 chars long and $tags_dash_fix is true // -> We'll consider this to be a ref to a post. @@ -341,7 +361,7 @@ // Set a lot of defaults as if we had received a complex URL: $m = ''; - $more = 1; // Display the extended entries' text + memorize_param( 'more', 'integer', 1, 1 ); // Display the extended entries' text if( preg_match( '#^p([0-9]+)$#', $last_part, $req_post ) ) { // The last param is of the form p000 @@ -520,7 +540,10 @@ ) { // Redirect permanently to the item main/canonical permanent url in the current collection: $Debuglog->add( 'Redirecting to correct canonical slug but stay in current collection', 'url_decode_part_2' ); - header_redirect( $Item->get_permanent_url( '', $Blog->get( 'url' ), '&', array(), $blog ), 301 ); + $canonical_url = $Item->get_permanent_url( '', $Blog->get( 'url' ), '&', array(), $blog ); + // Keep ONLY allowed params from current URL in the canonical URL by configs AND Item's switchable params: + $canonical_url = url_keep_canonicals_params( $canonical_url, '&', array_keys( $Item->get_switchable_params() ) ); + header_redirect( $canonical_url, 301 ); // Exit here. } } @@ -671,7 +694,7 @@ } elseif( !empty($preview) ) { // Preview - $disp = 'single'; + memorize_param( 'disp', 'string', 'single', 'single' ); // Consider this as an admin hit! $Hit->hit_type = 'admin'; } @@ -699,58 +722,31 @@ } elseif( $Item->get_type_setting( 'usage' ) == 'page' ) { - $disp = 'page'; + memorize_param( 'disp', 'string', 'page', 'page' ); } elseif( $Item->get_type_setting( 'usage' ) == 'widget-page' ) { - $disp = 'widget_page'; + memorize_param( 'disp', 'string', 'widget_page', 'widget_page' ); } else { - $disp = 'single'; + memorize_param( 'disp', 'string', 'single', 'single' ); } } elseif( $disp == '-' || ( $disp == 'front' && $disp == $Blog->get_setting( 'front_disp' ) ) ) { // No specific request of any kind OR $requested_disp = $disp; // We consider this is home front page: - $disp = $Blog->get_setting( 'front_disp' ); + memorize_param( 'disp', 'string', $Blog->get_setting( 'front_disp' ), $Blog->get_setting( 'front_disp' ) ); // Note: the above is where we MIGHT in fact set $disp = 'front'; $is_front = true; // we have detected that we are displaying the front page - // Do we need to handle the canoncial url? - if( ( $Blog->get_setting( 'canonical_homepage' ) && $redir == 'yes' ) - || $Blog->get_setting( 'relcanonical_homepage' ) - || $Blog->get_setting( 'self_canonical_homepage' ) ) - { // Check if the URL was canonical: - $canonical_url = $Blog->gen_blogurl(); - // Consider URL with possible params like disp=front or coll_locale=en-US as front canonical URL of the current Collection: - $current_url = preg_replace( '#[\?&]((coll_locale=[^&]+|disp='.preg_quote( $disp ).')(&|$))+#', '', $ReqURL ); - if( ! is_same_url( $current_url, $canonical_url, $Blog->get_setting( 'http_protocol' ) == 'allow_both' ) ) - { // We are not on the canonical blog url: - if( $Blog->get_setting( 'canonical_homepage' ) && - $redir == 'yes' && - $requested_disp != 'front' ) // Do NOT redirect when current requested URL is like ?disp=front - { // REDIRECT TO THE CANONICAL URL: - header_redirect( $canonical_url, ( empty( $display_containers ) && empty( $display_includes ) && empty( $_GET['debug'] ) ) ? 301 : 303 ); - } - elseif( $Blog->get_setting( 'relcanonical_homepage' ) ) - { // Use link rel="canoncial": - add_headline( '' ); - } - } - elseif( $Blog->get_setting( 'self_canonical_homepage' ) ) - { // Use self-referencing rel="canonical" tag: - add_headline( '' ); - } - } - if( $disp == 'single' ) { // We must find first item from disp=posts and display it on front page: if( $Item = & $Blog->get_first_mainlist_Item() ) { // The item is found, Use it: - set_param( 'p', $Item->ID ); + memorize_param( 'p', 'integer', $Item->ID, $Item->ID ); $c = 1; // Display comments } @@ -759,10 +755,9 @@ $Messages->add( sprintf( T_('Front page is set to display first post but there is nothing to display.'), $p ), 'error' ); } } - - if( $disp == 'page' ) + elseif( $disp == 'page' ) { // Specific page is displayed on front page - set_param( 'p', $Blog->get_setting('front_post_ID') ); + memorize_param( 'p', 'integer', $Blog->get_setting( 'front_post_ID' ), $Blog->get_setting( 'front_post_ID' ) ); $c = 1; // Display comments $ItemCache = & get_ItemCache(); @@ -774,7 +769,67 @@ } elseif( $Item->get_type_setting( 'usage' ) == 'widget-page' ) { // Switch to proper disp for Widget-Page Item in order to set correct filters on init $MainList: - $disp = 'widget_page'; + memorize_param( 'disp', 'string', 'widget_page', 'widget_page' ); + } + } +} + +if( $disp == 'terms' ) +{ // Display a page of terms & conditions: + $terms_item_ID = intval( $Settings->get( 'site_terms' ) ); + if( $Settings->get( 'site_terms_enabled' ) && $terms_item_ID > 0 ) + { // Only if item ID is defined for terms page: + memorize_param( 'p', 'integer' , $terms_item_ID, $terms_item_ID ); + $c = 0; // Don't display comments + + $ItemCache = & get_ItemCache(); + $Item = & $ItemCache->get_by_ID( $p, false ); + + if( is_logged_in() && $UserSettings->get( 'terms_accepted', $current_User->ID ) ) + { // Display the message if current user already accepted the terms: + $Messages->add( T_('You already accepted these terms.'), 'success' ); + } + + // Don't redirect to permanent url of the page: + $redir = 'no'; + } +} + +if( ! empty( $is_front ) ) +{ // Do we need to handle the canoncial url for front page? + if( ( $Blog->get_setting( 'canonical_homepage' ) && $redir == 'yes' ) + || $Blog->get_setting( 'relcanonical_homepage' ) + || $Blog->get_setting( 'self_canonical_homepage' ) ) + { // Check if the URL was canonical: + $canonical_url = $Blog->gen_blogurl(); + if( ! empty( $Item ) ) + { // Also keep front Item's switchable params in the collection canonical URL: + $keep_additional_front_canonicals_params = array_keys( $Item->get_switchable_params() ); + } + else + { // No additional canonicals params for current front page: + $keep_additional_front_canonicals_params = array(); + } + // Keep ONLY allowed params from current URL in the canonical URL by configs AND additional params if they are allowed depending on front disp: + $canonical_url = url_keep_canonicals_params( $canonical_url, '&', $keep_additional_front_canonicals_params ); + // Consider URL with possible params like disp=front or coll_locale=en-US as front canonical URL of the current Collection: + $current_url = preg_replace( '#[\?&]((coll_locale=[^&]+|disp='.preg_quote( $disp ).')(&|$))+#', '', $ReqURL ); + if( ! is_same_url( $current_url, $canonical_url, $Blog->get_setting( 'http_protocol' ) == 'allow_both' ) ) + { // We are not on the canonical blog url: + if( $Blog->get_setting( 'canonical_homepage' ) && + $redir == 'yes' && + $requested_disp != 'front' ) // Do NOT redirect when current requested URL is like ?disp=front + { // REDIRECT TO THE CANONICAL URL: + header_redirect( $canonical_url, ( empty( $display_containers ) && empty( $display_includes ) && empty( $_GET['debug'] ) ) ? 301 : 303 ); + } + elseif( $Blog->get_setting( 'relcanonical_homepage' ) ) + { // Use link rel="canoncial": + add_headline( '' ); + } + } + elseif( $Blog->get_setting( 'self_canonical_homepage' ) ) + { // Use self-referencing rel="canonical" tag: + add_headline( '' ); } } } @@ -863,27 +918,6 @@ reset_user_profile_view_ts( $user_ID ); } -if( $disp == 'terms' ) -{ // Display a page of terms & conditions: - $terms_item_ID = intval( $Settings->get( 'site_terms' ) ); - if( $Settings->get( 'site_terms_enabled' ) && $terms_item_ID > 0 ) - { // Only if item ID is defined for terms page: - set_param( 'p', $terms_item_ID ); - $c = 0; // Don't display comments - - $ItemCache = & get_ItemCache(); - $Item = & $ItemCache->get_by_ID( $p, false ); - - if( is_logged_in() && $UserSettings->get( 'terms_accepted', $current_User->ID ) ) - { // Display the message if current user already accepted the terms: - $Messages->add( T_('You already accepted these terms.'), 'success' ); - } - - // Don't redirect to permanent url of the page: - $redir = 'no'; - } -} - // Check if terms & conditions should be accepted by current user: if( is_logged_in() && // Only for logged in users ! in_array( $disp, array( 'terms', 'help', 'msgform', 'activateinfo' ) ) && // Allow these pages @@ -970,7 +1004,7 @@ // Because a lot of bloggers will delete skins, we have to make this fool proof with extra checking: if( !empty( $skin ) && !skin_exists( $skin ) ) { // We want to use a skin, but it doesn't exist! - $err_msg = sprintf( T_('The skin [%s] set for blog [%s] does not exist. It must be properly set in the blog properties or properly overriden in a stub file.'), + $err_msg = sprintf( T_('The skin [%s] set for blog [%s] does not exist.'), htmlspecialchars($skin), $Blog->dget('shortname'), 'href="'.$admin_url.'?ctrl=coll_settings&tab=skin&blog='.$Blog->ID.'"' ); diff --git a/inc/_core/__core.init.php b/inc/_core/__core.init.php index 5e0c852be7b..1bcc2b840e0 100644 --- a/inc/_core/__core.init.php +++ b/inc/_core/__core.init.php @@ -1134,13 +1134,13 @@ function build_evobar_menu() global $Settings; - $perm_admin_normal = $current_User->check_perm( 'admin', 'normal' ); - $perm_admin_restricted = $current_User->check_perm( 'admin', 'restricted' ); - $perm_users_view = $current_User->check_perm( 'users', 'view' ); - $perm_options = $current_User->check_perm( 'options', 'view' ); - $perm_spam = $current_User->check_perm( 'spamblacklist', 'view' ); - $perm_emails = $current_User->check_perm( 'emails', 'view' ); - $perm_maintenance = $current_User->check_perm( 'maintenance', 'upgrade' ); + $perm_admin_normal = check_user_perm( 'admin', 'normal' ); + $perm_admin_restricted = check_user_perm( 'admin', 'restricted' ); + $perm_users_view = check_user_perm( 'users', 'view' ); + $perm_options = check_user_perm( 'options', 'view' ); + $perm_spam = check_user_perm( 'spamblacklist', 'view' ); + $perm_emails = check_user_perm( 'emails', 'view' ); + $perm_maintenance = check_user_perm( 'maintenance', 'upgrade' ); $entries = NULL; $working_blog = get_working_blog(); @@ -1183,7 +1183,7 @@ function build_evobar_menu() ) ); - if( $perm_admin_normal && $current_User->check_perm( 'options', 'view' ) ) + if( $perm_admin_normal && check_user_perm( 'options', 'view' ) ) { // If current User has an access to backoffice and can view settings: $entries['site']['entries'][] = array( 'separator' => true ); $entries['site']['entries']['settings'] = array( @@ -1398,8 +1398,8 @@ function build_evobar_menu() if( ( ! is_admin_page() || ! empty( $activate_collection_toolbar ) ) && ! empty( $Blog ) ) { // A collection is currently selected AND we can activate toolbar items for selected collection: - if( $current_User->check_perm( 'blog_post_statuses', 'edit', false, $Blog->ID ) || - $current_User->check_perm( 'blog_item_propose', 'edit', false, $Blog->ID ) ) + if( check_user_perm( 'blog_post_statuses', 'edit', false, $Blog->ID ) || + check_user_perm( 'blog_item_propose', 'edit', false, $Blog->ID ) ) { // We have permission to add a post with at least one status: global $disp, $ctrl, $action, $Item, $edited_Item; if( ( $disp == 'edit' || $disp == 'proposechange' || $ctrl == 'items' ) && @@ -1433,7 +1433,7 @@ function build_evobar_menu() if( ! empty( $Item ) || ( ! empty( $edited_Item ) && $edited_Item->ID > 0 ) ) { // Display menu entries to edit and view the post in back-office: $menu_Item = empty( $Item ) ? $edited_Item : $Item; - if( $perm_admin_restricted && $current_User->check_perm( 'item_post!CURSTATUS', 'edit', false, $menu_Item ) ) + if( $perm_admin_restricted && check_user_perm( 'item_post!CURSTATUS', 'edit', false, $menu_Item ) ) { // Menu item to edit post in back-office: $entries['page']['entries']['edit_back'] = array( 'text' => sprintf( T_('Edit "%s" in Back-Office'), $menu_Item->get_type_setting( 'name' ) ).'…', @@ -1452,7 +1452,7 @@ function build_evobar_menu() ); } } - if( $perm_admin_restricted && $current_User->check_perm( 'blog_post_statuses', 'edit', false, $Blog->ID ) ) + if( $perm_admin_restricted && check_user_perm( 'blog_post_statuses', 'edit', false, $Blog->ID ) ) { // Menu item to view post in back-office: $entries['page']['entries']['view_back'] = array( 'text' => T_('View in Back-Office').'…', @@ -1499,7 +1499,7 @@ function build_evobar_menu() } if( $featured_intro_Item->ID > 0 ) { // Display menu entries to edit and view the post in back-office: - if( $perm_admin_restricted && $current_User->check_perm( 'item_post!CURSTATUS', 'edit', false, $featured_intro_Item ) ) + if( $perm_admin_restricted && check_user_perm( 'item_post!CURSTATUS', 'edit', false, $featured_intro_Item ) ) { // Menu item to edit post in back-office: $entries['page']['entries']['edit_back'] = array( 'text' => sprintf( T_('Edit "%s" in Back-Office'), $featured_intro_Item->get_type_setting( 'name' ) ).'…', @@ -1508,7 +1508,7 @@ function build_evobar_menu() 'shortcut-top' => $Blog->get_setting( 'in_skin_editing' ) ? 'ctrl+f2' : 'f2,ctrl+f2', ); } - if( $perm_admin_restricted && $current_User->check_perm( 'blog_post_statuses', 'edit', false, $Blog->ID ) ) + if( $perm_admin_restricted && check_user_perm( 'blog_post_statuses', 'edit', false, $Blog->ID ) ) { // Menu item to view post in back-office: $entries['page']['entries']['view_back'] = array( 'text' => T_('View in Back-Office').'…', @@ -1554,7 +1554,7 @@ function build_evobar_menu() ); $display_separator = false; - if( $current_User->check_perm( 'blog_ismember', 'view', false, $Blog->ID ) ) + if( check_user_perm( 'blog_ismember', 'view', false, $Blog->ID ) ) { // Check if current user has an access to post lists $items_url = $admin_url.'?ctrl=items&blog='.$Blog->ID.'&filter=restore'; @@ -1574,7 +1574,7 @@ function build_evobar_menu() $contents_submenu = array(); - if( $Blog->get_setting( 'use_workflow' ) && $current_User->check_perm( 'blog_can_be_assignee', 'edit', false, $Blog->ID ) ) + if( $Blog->get_setting( 'use_workflow' ) && check_user_perm( 'blog_can_be_assignee', 'edit', false, $Blog->ID ) ) { // Workflow view $contents_submenu['workflow'] = array( 'text' => T_('Workflow view').'…', @@ -1633,8 +1633,8 @@ function build_evobar_menu() $display_separator = true; } - $perm_comments = $current_User->check_perm( 'blog_comments', 'view', false, $Blog->ID ); - if( $perm_comments || $current_User->check_perm( 'meta_comment', 'view', false, $Blog->ID ) ) + $perm_comments = check_user_perm( 'blog_comments', 'view', false, $Blog->ID ); + if( $perm_comments || check_user_perm( 'meta_comment', 'view', false, $Blog->ID ) ) { // Initialize comments menu tab if user can view normal or internal comments of the collection: $entries['blog']['entries']['comments'] = array( 'text' => T_('Comments').'…', @@ -1646,7 +1646,7 @@ function build_evobar_menu() } // Chapters / Categories: - if( $current_User->check_perm( 'blog_cats', 'edit', false, $Blog->ID ) ) + if( check_user_perm( 'blog_cats', 'edit', false, $Blog->ID ) ) { // Either permission for a specific blog or the global permission: $entries['blog']['entries']['chapters'] = array( 'text' => T_('Categories').'…', @@ -1664,7 +1664,7 @@ function build_evobar_menu() $entries['blog']['entries']['files'] = NULL; // BLOG SETTINGS: - if( $current_User->check_perm( 'blog_properties', 'edit', false, $Blog->ID ) ) + if( check_user_perm( 'blog_properties', 'edit', false, $Blog->ID ) ) { // We have permission to edit blog properties: $blog_param = '&blog='.$Blog->ID; @@ -1692,6 +1692,10 @@ function build_evobar_menu() 'text' => T_('User directory').'…', 'href' => $admin_url.'?ctrl=coll_settings&tab=userdir'.$blog_param, ), + 'search' => array( + 'text' => T_('Search').'…', + 'href' => $admin_url.'?ctrl=coll_settings&tab=search'.$blog_param, + ), 'other' => array( 'text' => T_('Other displays').'…', 'href' => $admin_url.'?ctrl=coll_settings&tab=other'.$blog_param, @@ -1762,7 +1766,7 @@ function build_evobar_menu() ) ); - if( $current_User->check_perm( 'options', 'view', false, $Blog->ID ) ) + if( check_user_perm( 'options', 'view', false, $Blog->ID ) ) { // Post Types & Statuses $entries['blog']['entries']['general']['entries']['item_types'] = array( 'text' => T_('Item Types').'…', @@ -1791,7 +1795,7 @@ function build_evobar_menu() ); } - if( $current_User->check_perm( 'options', 'view' ) ) + if( check_user_perm( 'options', 'view' ) ) { // Check if current user has a permission to view the common settings of the blogs $entries['blog']['entries']['general']['entries']['common_settings'] = array( 'text' => T_('Common Settings').'…', @@ -1806,8 +1810,8 @@ function build_evobar_menu() { // Only front-office collection pages: if( $perm_admin_restricted && - ( ( $Settings->get( 'site_skins_enabled' ) && $current_User->check_perm( 'options', 'edit' ) ) || - $current_User->check_perm( 'blog_properties', 'edit', false, $Blog->ID ) ) + ( ( $Settings->get( 'site_skins_enabled' ) && check_user_perm( 'options', 'edit' ) ) || + check_user_perm( 'blog_properties', 'edit', false, $Blog->ID ) ) ) { // If current user has an access to back-office and to edit site or collection properties: global $Session; @@ -1822,7 +1826,7 @@ function build_evobar_menu() ); } - if( $perm_admin_restricted && $current_User->check_perm( 'blog_properties', 'edit', false, $Blog->ID ) ) + if( $perm_admin_restricted && check_user_perm( 'blog_properties', 'edit', false, $Blog->ID ) ) { // If current user has an access to back-office and to edit collection properties: // Display menu item "Features" with depending on $disp: global $disp, $disp_detail; @@ -1929,6 +1933,11 @@ function build_evobar_menu() 'text' => $debug_text, 'disabled' => true, ); + + $dev_entries['defer'] = array( + 'text' => use_defer() ? 'Using Deferred loading' : 'Using Normal loading', + 'disabled' => true, + ); } if( ! is_admin_page() && ! empty( $dev_entries ) ) @@ -2126,7 +2135,7 @@ function build_evobar_menu() 'entry_class' => 'rwdhide' ); - if( $current_User->check_perm( 'admin', 'normal' ) && $current_User->check_perm( 'options', 'view' ) ) + if( check_user_perm( 'admin', 'normal' ) && check_user_perm( 'options', 'view' ) ) { // Make time as link to Timezone settings if permission $entries['time']['disabled'] = false; $entries['time']['href'] = $admin_url.'?ctrl=time'; @@ -2185,9 +2194,9 @@ function build_menu_3() */ global $AdminUI; - $perm_admin_normal = $current_User->check_perm( 'admin', 'normal' ); - $perm_options = $current_User->check_perm( 'options', 'view' ); - $perm_users = $current_User->check_perm( 'users', 'view' ); + $perm_admin_normal = check_user_perm( 'admin', 'normal' ); + $perm_options = check_user_perm( 'options', 'view' ); + $perm_users = check_user_perm( 'users', 'view' ); /**** Users | My profile ****/ if( $perm_admin_normal && $perm_users ) @@ -2254,7 +2263,7 @@ function build_menu_3() $AdminUI->add_menu_entries( NULL, array( 'users' => $users_entries ) ); - if( $current_User->check_perm( 'orgs', 'create' ) ) + if( check_user_perm( 'orgs', 'create' ) ) { // Display a menu item for organizations if user has a perm at least to create own organization: $AdminUI->add_menu_entries( array( 'users' ), array( 'organizations' => array( @@ -2264,7 +2273,7 @@ function build_menu_3() } /**** Emails ****/ - $perm_emails = $current_User->check_perm( 'emails', 'view' ); + $perm_emails = check_user_perm( 'emails', 'view' ); if( $perm_admin_normal && $perm_options && $perm_emails ) { // Permission to view email management: $AdminUI->add_menu_entries( NULL, array( 'email' => array( @@ -2330,7 +2339,7 @@ function build_menu_3() ), 'campaigns' ); } - if( $current_User->check_perm( 'emails', 'edit' ) ) + if( check_user_perm( 'emails', 'edit' ) ) { // Allow to test a returned email and smtp sending only if user has a permission to edit email settings: $AdminUI->add_menu_entries( array( 'email', 'return' ), array( 'test' => array( @@ -2354,7 +2363,7 @@ function build_menu_3() 'href' => $admin_url.'?ctrl=system' ) ) ); - $perm_spam = $current_User->check_perm( 'spamblacklist', 'view' ); + $perm_spam = check_user_perm( 'spamblacklist', 'view' ); if( $perm_admin_normal && ( $perm_options || $perm_spam ) ) { // Permission to view tools or antispam. @@ -2408,7 +2417,7 @@ function build_menu_3() 'text' => T_('Countries'), 'href' => '?ctrl=antispam&tab3=countries' ) ) ); - if( $current_User->check_perm( 'stats', 'list' ) ) + if( check_user_perm( 'stats', 'list' ) ) { $AdminUI->add_menu_entries( array( 'options', 'antispam' ), array( 'domains' => array( @@ -2421,7 +2430,7 @@ function build_menu_3() 'text' => T_('Settings'), 'href' => '?ctrl=antispam&tab3=settings' ) ) ); - if( $current_User->check_perm( 'options', 'edit' ) ) + if( check_user_perm( 'options', 'edit' ) ) { $AdminUI->add_menu_entries( array( 'options', 'antispam' ), array( 'tools' => array( @@ -2487,7 +2496,7 @@ function build_menu_3() ) ), ) ); - if( $current_User->check_perm( 'options', 'edit' ) ) + if( check_user_perm( 'options', 'edit' ) ) { $AdminUI->add_menu_entries( 'options', array( 'syslog' => array( diff --git a/inc/_core/_misc.funcs.php b/inc/_core/_misc.funcs.php index 6ad1c7070c7..221cd5253de 100644 --- a/inc/_core/_misc.funcs.php +++ b/inc/_core/_misc.funcs.php @@ -30,6 +30,8 @@ // Load utf8 support functions load_funcs( '_ext/_portable_utf8.php' ); +load_funcs( '_ext/random/random.php' ); + /** * Call a method for all modules in a row @@ -117,7 +119,7 @@ function load_db_schema( $inlcude_plugins = false ) // Load modules: foreach( $modules as $module ) { - echo get_install_format_text( 'Loading module: '.$module.'/model/_'.$module.'.install.php
    ', 'br' ); + echo get_install_format_text_and_log( 'Loading module: '.$module.'/model/_'.$module.'.install.php
    ', 'br' ); require_once $inc_path.$module.'/model/_'.$module.'.install.php'; } @@ -687,8 +689,11 @@ function strmaxwords( $str, $maxwords = 50, $params = array() ) } if( $params['always_continue'] || $maxwords < 1 ) - { // we want a continued text - $str .= ' '.$params['continued_text'].''; + { // we want a continued text if avoid_end_hellip is not set: + if( ! isset( $params['avoid_end_hellip'] ) ) + { + $str .= ' '.$params['continued_text'].''; + } } return $str; @@ -1637,9 +1642,11 @@ function make_clickable_callback( $text, $moredelim = '&', $additional_attrs { $additional_attrs = ' '.trim( $additional_attrs ); } - //return $text; - /*preg_match( '/([.\r\n]+?)<\/code>/i', $text, $matches ); - pre_dump( $text, $matches );*/ + + // Add style class to break long urls: + $additional_attrs = stripos( $additional_attrs, ' class="' ) === false + ? $additional_attrs.' class="linebreak"' + : preg_replace( '/ class="([^"]*)"/i', ' class="$1 linebreak"', $additional_attrs ); $pattern_domain = '([\p{L}0-9\-]+\.[\p{L}0-9\-.\~]+)'; // a domain name (not very strict) $text = preg_replace( @@ -3142,29 +3149,46 @@ function debug_die( $additional_info = '', $params = array() ) header($status_header); } - echo '
    '; - echo '

    '.T_('An unexpected error has occurred!').'

    '; - echo '

    '.T_('If this error persists, please report it to the administrator.').'

    '; - echo '

    '.T_('Go back to home page').'

    '; - echo '
    '; - + $too_many_connections = false; if( ! empty( $additional_info ) ) - { - echo '
    '; - if( $debug || $display_errors_on_production ) - { // Display additional info only in debug mode or when it was explicitly set by display_errors_on_production setting because it can reveal system info to hackers and greatly facilitate exploits - echo '

    '.T_('Additional information about this error:').'

    '; - echo $additional_info; - } - else + { //Handling of "Too many connections": + $find_token = 'Too many connections'; + + if( preg_match( "/{$find_token}/i", $additional_info ) ) { - echo '

    Enable debugging to get additional information about this error.

    ' . get_manual_link('debugging','How to enable debug mode?'); + load_funcs( 'skins/_skin.funcs.php' ); + $too_many_connections = true; + require skin_fallback_path( 'too_many_connections.main.php', 6 ); + http_response_code( 503 ); } + } + + if( ! $too_many_connections ) + { + echo '
    '; + echo '

    '.T_('An unexpected error has occurred!').'

    '; + echo '

    '.T_('If this error persists, please report it to the administrator.').'

    '; + echo '

    '.T_('Go back to home page').'

    '; echo '
    '; - // Append the error text to AJAX log if it is AJAX request - ajax_log_add( $additional_info, 'error' ); - ajax_log_display(); + if( ! empty( $additional_info ) ) + { + echo '
    '; + if( $debug || $display_errors_on_production ) + { // Display additional info only in debug mode or when it was explicitly set by display_errors_on_production setting because it can reveal system info to hackers and greatly facilitate exploits + echo '

    '.T_('Additional information about this error:').'

    '; + echo $additional_info; + } + else + { + echo '

    Enable debugging to get additional information about this error.

    ' . get_manual_link('debugging','How to enable debug mode?'); + } + echo '
    '; + + // Append the error text to AJAX log if it is AJAX request + ajax_log_add( $additional_info, 'error' ); + ajax_log_display(); + } } } @@ -3370,10 +3394,10 @@ function debug_info( $force = false, $force_clean = false ) $relative_to = ( is_admin_page() ? 'rsc_url' : 'blog' ); - require_js( '#jqueryUI#', $relative_to, false, true ); + require_js_defer( '#jqueryUI#', $relative_to, true ); require_css( '#jqueryUI_css#', $relative_to, NULL, NULL, '#', true ); - require_js( 'debug_jslog.js', $relative_to, false, true ); - require_js( 'jquery/jquery.cookie.min.js', $relative_to, false, true ); + require_js_defer( 'debug_jslog.js', $relative_to, true ); + require_js_defer( 'ext:jquery/cookie/jquery.cookie.min.js', $relative_to, true ); $jslog_style_cookies = param_cookie( 'jslog_style', 'string' ); $jslog_styles = array(); @@ -3482,8 +3506,24 @@ function debug_info( $force = false, $force_clean = false ) } // FULL DEBUG INFO(s) FROM PREVIOUS SESSION(s), after REDIRECT(s): - if( isset( $Session ) && ( $sess_debug_infos = $Session->get( 'debug_infos' ) ) && ! empty( $sess_debug_infos ) ) - { + $get_redirected_debuginfo_from_sess_ID = param( 'get_redirected_debuginfo_from_sess_ID', 'integer' ); + if( ! empty( $get_redirected_debuginfo_from_sess_ID ) ) + { // Get Session by ID for debug info from redirected page: + // (This is used for redirect from different domain) + $debug_info_Session = new Session( $get_redirected_debuginfo_from_sess_ID ); + } + elseif( isset( $Session ) ) + { // Use current Session for debug info from redirected page: + $debug_info_Session = $Session; + } + + if( isset( $debug_info_Session ) && ! empty( $debug_info_Session->ID ) ) + { // Get debug info from redirected page: + $sess_debug_infos = $debug_info_Session->get( 'debug_infos' ); + } + + if( ! empty( $sess_debug_infos ) ) + { // Display debug info from redirected page: $count_sess_debug_infos = count( $sess_debug_infos ); if( $count_sess_debug_infos > 1 ) { // Links to those Debuglogs: @@ -3545,7 +3585,7 @@ function debug_info( $force = false, $force_clean = false ) // So in that case we want them to move over to the next page... if( $http_response_code < 300 || $http_response_code >= 400 ) { // This is NOT a 3xx redirect, assume debuglogs have been seen & delete them: - $Session->delete( 'debug_infos' ); + $debug_info_Session->delete( 'debug_infos' ); } echo "\n\n\n"; @@ -3690,21 +3730,8 @@ function debug_info( $force = false, $force_clean = false ) // add jquery.tablesorter to the "Debug info" table. $relative_to = ( is_admin_page() ? 'rsc_url' : 'blog' ); - require_js( 'jquery/jquery.tablesorter.min.js', $relative_to, true, true ); - echo ' - '; + require_js_defer( 'ext:jquery/tablesorter/jquery.tablesorter.min.js', $relative_to, true ); + require_js_defer( 'src/evo_init_debug_timer.js', $relative_to, true ); } @@ -4653,7 +4680,7 @@ function mail_autoinsert_user_data( $text, $User = NULL, $format = 'text', $user */ function mail_template( $template_name, $format = 'auto', $params = array(), $User = NULL ) { - global $current_charset, $current_User; + global $current_charset; global $track_email_image_load, $track_email_click_html, $track_email_click_plain_text; $params = array_merge( array( @@ -5054,7 +5081,7 @@ function action_icon( $title, $icon, $url, $word = NULL, $icon_weight = NULL, $w // OR we default to icon because the user doesn't want the word either!! $icon_attribs = array_merge( array( - 'title' => $title + 'title' => false, // No need to set attribute "ttile" for icon because parent already has it ), $icon_attribs ); if( $icon_s = get_icon( $icon, 'imgtag', $icon_attribs, true ) ) @@ -5934,7 +5961,7 @@ function generate_random_key( $length = 32, $keychars = 'abcdefghijklmnopqrstuvw for( $i = 0; $i < $length; $i++ ) { - $key .= $keychars[mt_rand(0, $rnd_max)]; // get a random character out of $keychars + $key .= $keychars[random_int(0, $rnd_max)]; // get a random character out of $keychars } return $key; @@ -7714,34 +7741,53 @@ function is_ip_url_domain( $url ) */ function save_to_file( $data, $filename, $mode = 'a' ) { - global $Settings; + global $Settings, $evo_save_file_error_msg; - if( ! file_exists($filename) ) - { // Create target file - @touch( $filename ); + if( ! file_exists( $filename ) ) + { // Try to create a target file: + if( ! @touch( $filename ) ) + { // If file could not be created: + $evo_save_file_error_msg = T_('File could not be created!'); + return false; + } // Doesn't work during installation - if( !empty($Settings) ) + if( ! empty( $Settings ) ) { - $chmod = $Settings->get('fm_default_chmod_file'); - @chmod( $filename, octdec($chmod) ); + $chmod = $Settings->get( 'fm_default_chmod_file' ); + @chmod( $filename, octdec( $chmod ) ); } } - if( ! is_writable($filename) ) - { + if( ! is_writable( $filename ) ) + { // File is not writable: + $evo_save_file_error_msg = T_('File is not writable!'); return false; } - $f = @fopen( $filename, $mode ); - $ok = @fwrite( $f, $data ); + if( ! ( $f = @fopen( $filename, $mode ) ) ) + { // Could not open file: + $evo_save_file_error_msg = T_('File could not be opened for writing data!'); + return false; + } + if( ! @fwrite( $f, $data ) ) + { // Could not write data into file: + $evo_save_file_error_msg = T_('Data could not be written to the file!'); + return false; + } @fclose( $f ); - if( $ok && file_exists($filename) ) - { - return $filename; + if( ! file_exists( $filename ) ) + { // Additonal check for existing file on disk: + $evo_save_file_error_msg = T_('File doesn\'t exist!'); + return false; } - return false; + + // Reset error log on success result: + $evo_save_file_error_msg = ''; + + // Return file name on success result: + return $filename; } @@ -7983,11 +8029,11 @@ function echo_editable_column_js( $params = array() ) $params = array_merge( array( 'column_selector' => '', // jQuery selector of cell 'ajax_url' => '', // AJAX url to update a column value - 'options' => array(), // Key = Value of option, Value = Title of option + 'options' => array(), // Key = Value of option, Value = Title of option. Do not use Javascript code to populate this - use 'options_eval' param to do this. 'new_field_name' => '', // Name of _POST variable that will be send to ajax request with new value 'ID_value' => '', // jQuery to get value of ID 'ID_name' => '', // ID of field in DB - 'tooltip' => TS_('Click to edit'), + 'tooltip' => T_('Click to edit'), 'colored_cells' => false, // Use TRUE when colors are used for background of cell 'print_init_tags' => true, // Use FALSE to don't print - - -set( $setting_name, $value ); + + // Update the folding setting for current user + $UserSettings->dbupdate(); + } +} + + /** * Get html code of bootstrap dropdown element * @@ -8734,12 +8639,16 @@ function evo_version_compare( $version1, $version2, $operator = NULL ) * @param string Format (Used for CLI mode) * @return string Prepared text */ -function get_install_format_text( $text, $format = 'string' ) +function get_install_format_text_and_log( $text, $format = 'string' ) { - global $display; + global $display, $logs_path, $log_file_handle, $avoid_log_file; if( empty( $display ) || $display != 'cli' ) { // Don't touch text for non CLI modes: + if( ! $avoid_log_file ) + { // Include in log file: + prepare_install_log_message( $text ); + } return $text; } @@ -8800,11 +8709,164 @@ function get_install_format_text( $text, $format = 'string' ) // Replace all html entities like " ", "»", "«" to readable chars: $text = html_entity_decode( $text ); - + + if( ! $avoid_log_file ) + { // Include in log file: + prepare_install_log_message( $text ); + } + return $text; } +/** +* Start to log into file on disk +*/ +function start_install_log( $log_file_name ) +{ // TODO: Factorize with start_log(): + global $rsc_url, $app_version_long, $log_file_handle, $logs_path, $servertimenow; + + // Get file path for log: + $log_file_path = $logs_path.date( 'Y-m-d-H-i-s', $servertimenow ).'-'.$log_file_name.'.html'; + + // Check log path is writeable or not: + if ( ! is_writable( $logs_path ) ) { + + return false; + } + + // Try to create log file: + if( ! ( $log_file_handle = fopen( $log_file_path, 'w' ) ) ) + { + return false; + } + + // Write header of the log file: + install_log_to_file( ''."\r\n" + .''."\r\n" + .''."\r\n" + .''."\r\n" + .''."\r\n" + .''."\r\n" + .'
    ' ); +} + + +/** +* End of log into file on disk +*/ +function end_install_log() +{ // TODO: Factorize with end_log(): + global $log_file_handle; + + // Write footer of the log file: + install_log_to_file( '
    '."\r\n" + .''."\r\n" + .'' ); + + if( isset( $log_file_handle ) && $log_file_handle ) + { // Close the log file: + fclose( $log_file_handle ); + } +} + + +/** +* Log a message on screen and into file on disk +* +* @param string Message +* @param string Type: 'success', 'error', 'warning' +* @param string HTML tag for type/styled log: 'p', 'span', 'b', etc. +* @param boolean TRUE to display label +*/ +function prepare_install_log_message( $message, $type = NULL, $type_html_tag = 'p', $display_label = true ) +{ // TODO: Factorize with log(): + global $log_file_handle; + + if( ! isset( $log_file_handle ) || ! $log_file_handle ) + { + return false; + } + + $message = get_install_log( $message, $type, $type_html_tag, $display_label ); + + if( $message === false ) + { // Skip when message should not be displayed: + return; + } + + // Try to store a message into the log file on the disk: + install_log_to_file( $message ); +} + + +/** +* Get a log message +* +* @param string Message +* @param string Type: 'success', 'error', 'warning', 'info' +* @param string HTML tag for type/styled log: 'p', 'span', 'b', etc. +* @param boolean TRUE to display label +* @return string|FALSE Formatted log message, FALSE - when message should not be displayed +*/ +function get_install_log( $message, $type = NULL, $type_html_tag = 'p', $display_label = true ) +{ // TODO: Factorize with get_log(): + if( $message === '' ) + { // Don't log empty strings: + return false; + } + + switch( $type ) + { + case 'success': + $before = '<'.$type_html_tag.' class="text-success"> '; + $after = ''; + break; + + case 'error': + $before = '<'.$type_html_tag.' class="text-danger">'.( $display_label ? 'ERROR' : '' ).' '; + $after = ''; + break; + + case 'warning': + $before = '<'.$type_html_tag.' class="text-warning">'.( $display_label ? 'WARNING' : '' ).' '; + $after = ''; + break; + + case 'info': + $before = '<'.$type_html_tag.' class="text-info">'.( $display_label ? 'INFO' : '' ).' '; + $after = ''; + break; + + default: + $before = ''; + $after = ''; + break; + } + + return $before.$message.$after; +} + + +/** +* Log a message into file on disk +* +* @param string Message +*/ +function install_log_to_file( $message ) +{ // TODO: Factorize with log_to_file(): + global $log_file_handle; + + if( ! isset( $log_file_handle ) || ! $log_file_handle ) + { + return false; + } + + // Put a message into the log file on the disk: + fwrite( $log_file_handle, $message."\r\n" ); +} + + /** * Check if password should be transmitted in hashed format during Login * @@ -8843,8 +8905,50 @@ function render_inline_files( $content, $Object, $params = array() ) $params = array_merge( array( 'check_code_block' => false, 'clear_paragraph' => true, + 'render_tag_image' => true, + 'render_tag_file' => true, + 'render_tag_inline' => true, + 'render_tag_video' => true, + 'render_tag_audio' => true, + 'render_tag_thumbnail' => true, + 'render_tag_folder' => true, ), $params ); + $render_tags = array(); + if( $params['render_tag_image'] ) + { // Render short tag [image:] + $render_tags[] = 'image'; + } + if( $params['render_tag_file'] ) + { // Render short tag [file:] + $render_tags[] = 'file'; + } + if( $params['render_tag_inline'] ) + { // Render short tag [inline:] + $render_tags[] = 'inline'; + } + if( $params['render_tag_video'] ) + { // Render short tag [video:] + $render_tags[] = 'video'; + } + if( $params['render_tag_audio'] ) + { // Render short tag [audio:] + $render_tags[] = 'audio'; + } + if( $params['render_tag_thumbnail'] ) + { // Render short tag [thumbnail:] + $render_tags[] = 'thumbnail'; + } + if( $params['render_tag_folder'] ) + { // Render short tag [folder:] + $render_tags[] = 'folder'; + } + + if( empty( $render_tags ) ) + { // No tags for rendering: + return $content; + } + if( $params['check_code_block'] && ( ( stristr( $content, 'get_tag( '', '', '', '', $current_image_params['image_size'], '', '', '', - '', '', '', '', '', 1, NULL, 'border: none; max-width: 100%; height: auto;'.$image_style, false ); + '', '', $current_image_params['image_alt'], '', '', 1, NULL, 'border: none; max-width: 100%; height: auto;'.$image_style, false ); break; default: $inlines[ $current_inline ] = $File->get_tag( '', '', '', '', $current_image_params['image_size'], '', '', '', - ( empty( $current_file_params['class'] ) ? '' : $current_file_params['class'] ), '', '', '' ); + ( empty( $current_file_params['class'] ) ? '' : $current_file_params['class'] ), '', $current_image_params['image_alt'], '' ); } } } @@ -9197,6 +9323,7 @@ function render_inline_tags( $Object, $tags, $params = array() ) { global $thumbnail_sizes; + $thumbnail_alt = ''; $thumbnail_href = false; $thumbnail_rel = NULL; $thumbnail_additional_class = false; @@ -9211,11 +9338,29 @@ function render_inline_tags( $Object, $tags, $params = array() ) $inline_params = explode( ':', $inline[4] ); $opt_index = 0; - // TODO: Alt text: + // RegExp to detect HRef option: + $href_regexp = '#^(https?|\(\((.*?)\)\))$#i'; + + // Alt text: + if( isset( $inline_params[ $opt_index ] ) && + substr( $inline_params[ $opt_index ], 0, 1 ) != '.' && + ! preg_match( $href_regexp, $inline_params[ $opt_index ] ) && + ! in_array( $inline_params[ $opt_index ], array( 'small', 'medium', 'large', 'left', 'right' ) ) ) + { // Override the image File's alt text with provided in current inline tag: + if( $inline_params[ $opt_index ] == '-' ) + { // Alt text display is disabled: + $thumbnail_alt = '-'; + } + else + { // New image alt text was set: + $thumbnail_alt = strip_tags( $inline_params[ $opt_index ] ); + } + $opt_index++; + } // HRef: if( ! empty( $inline_params[ $opt_index ] ) && - preg_match( '#^(https?|\(\((.*?)\)\))$#i', $inline_params[ $opt_index ], $href_match ) ) + preg_match( $href_regexp, $inline_params[ $opt_index ], $href_match ) ) { if( stripos( $href_match[0], 'http' ) === 0 ) { // Absolute URL: @@ -9305,6 +9450,7 @@ function render_inline_tags( $Object, $tags, $params = array() ) 'image_link_title' => '', // can be text or #title# or #desc# 'image_link_rel' => $thumbnail_rel, 'image_class' => implode( ' ', $thumbnail_classes ), + 'image_alt' => $thumbnail_alt, ); switch( $object_class ) @@ -9743,7 +9889,7 @@ function get_social_media_image( $Item = NULL, $params = array() ) if( ! empty( $Item ) ) { // Try to get attached images $LinkOwner = new LinkItem( $Item ); - if( $LinkList = $LinkOwner->get_attachment_LinkList( 1000, 'cover,teaser,teaserperm,teaserlink', 'image', array( + if( $LinkList = $LinkOwner->get_attachment_LinkList( 1000, 'cover,background,teaser,teaserperm,teaserlink', 'image', array( 'sql_select_add' => ', CASE WHEN link_position = "cover" THEN 1 WHEN link_position IN ( "teaser", "teaserperm", "teaserlink" ) THEN 2 ELSE 3 END AS link_priority', 'sql_order_by' => 'link_priority ASC, link_order ASC' ) ) ) { // Item has linked files: @@ -9867,8 +10013,8 @@ function insert_image_links_block( $params ) } if( isset( $GLOBALS['files_Module'] ) - && ( ( $edited_Item && $current_User->check_perm( 'item_post!CURSTATUS', 'edit', false, $edited_Item ) ) || ( empty( $edited_Item ) && $params['temp_ID'] ) ) - && $current_User->check_perm( 'files', 'view', false ) ) + && ( ( $edited_Item && check_user_perm( 'item_post!CURSTATUS', 'edit', false, $edited_Item ) ) || ( empty( $edited_Item ) && $params['temp_ID'] ) ) + && check_user_perm( 'files', 'view', false ) ) { // Files module is enabled, but in case of creating new posts we should show file attachments block only if user has all required permissions to attach files load_class( 'links/model/_linkitem.class.php', 'LinkItem' ); global $LinkOwner; // Initialize this object as global because this is used in many link functions @@ -9893,8 +10039,8 @@ function insert_image_links_block( $params ) } if( isset( $GLOBALS['files_Module'] ) - && $current_User->check_perm( 'comment!CURSTATUS', 'edit', false, $edited_Comment ) - && $current_User->check_perm( 'files', 'view', false ) ) + && check_user_perm( 'comment!CURSTATUS', 'edit', false, $edited_Comment ) + && check_user_perm( 'files', 'view', false ) ) { // Files module is enabled, but in case of creating new comments we should show file attachments block only if user has all required permissions to attach files load_class( 'links/model/_linkcomment.class.php', 'LinkComment' ); global $LinkOwner; // Initialize this object as global because this is used in many link functions @@ -9912,8 +10058,8 @@ function insert_image_links_block( $params ) $edited_EmailCampaign = $EmailCampaignCache->get_by_ID( $params['target_ID'] ); if( isset( $GLOBALS['files_Module'] ) - && $current_User->check_perm( 'emails', 'edit', false ) - && $current_User->check_perm( 'files', 'view', false ) ) + && check_user_perm( 'emails', 'edit', false ) + && check_user_perm( 'files', 'view', false ) ) { // Files module is enabled, but in case of creating new email campaign we should show file attachments block only if user has all required permissions to attach files load_class( 'links/model/_linkemailcampaign.class.php', 'LinkEmailCampaign' ); global $LinkOwner; // Initialize this object as global because this is used in many link functions @@ -9931,8 +10077,8 @@ function insert_image_links_block( $params ) $edited_Message = $MessageCache->get_by_ID( $params['target_ID'], false, false ); if( isset( $GLOBALS['files_Module'] ) - && $current_User->check_perm( 'perm_messaging', 'reply' ) - && $current_User->check_perm( 'files', 'view', false ) ) + && check_user_perm( 'perm_messaging', 'reply' ) + && check_user_perm( 'files', 'view', false ) ) { // Files module is enabled, but in case of creating new messages we should show file attachments block only if user has all required permissions to attach files load_class( 'links/model/_linkmessage.class.php', 'LinkMessage' ); global $LinkOwner; // Initialize this object as global because this is used in many link functions @@ -10004,7 +10150,7 @@ function get_csv_line( $row, $delimiter = ';', $enclosure = '"', $eol = "\n" ) */ function display_importer_upload_panel( $params = array() ) { - global $admin_url, $current_User, $media_path; + global $admin_url, $media_path; $params = array_merge( array( 'folder' => '', @@ -10045,14 +10191,14 @@ function display_importer_upload_panel( $params = array() ) $FileRootCache = & get_FileRootCache(); $FileRoot = & $FileRootCache->get_by_type_and_ID( 'import', '0', true ); - $import_perm_view = $current_User->check_perm( 'files', 'view', false, $FileRoot ); + $import_perm_view = check_user_perm( 'files', 'view', false, $FileRoot ); if( $import_perm_view ) { // Current user must has access to the import dir - if( $current_User->check_perm( 'files', 'edit_allowed', false, $FileRoot ) ) + if( check_user_perm( 'files', 'edit_allowed', false, $FileRoot ) ) { // User has full access $import_title = T_('Upload/Manage import files'); } - else if( $current_User->check_perm( 'files', 'add', false, $FileRoot ) ) + else if( check_user_perm( 'files', 'add', false, $FileRoot ) ) { // User can only upload the files to import root $import_title = T_('Upload import files'); } @@ -10509,4 +10655,101 @@ function get_querybuilder_operator( $operator ) return $operator; } } -?> + + +/** + * Temporary function to check if we should use defer when loading scripts. + */ +function use_defer() +{ + global $disp, $ReqPath, + $use_defer, + $use_defer_for_backoffice, + $use_defer_for_loggedin_users, + $use_defer_for_anonymous_users, + $use_defer_for_anonymous_disp_register, + $use_defer_for_anonymous_disp_register_finish, + $use_defer_for_anonymous_disp_users, + $use_defer_for_anonymous_disp_anonpost, + $use_defer_for_loggedin_disp_single_page, + $use_defer_for_loggedin_disp_front, + $use_defer_for_loggedin_disp_profile, + $use_defer_for_loggedin_disp_pwdchange, + $use_defer_for_loggedin_disp_edit, + $use_defer_for_loggedin_disp_proposechange, + $use_defer_for_loggedin_disp_edit_comment, + $use_defer_for_loggedin_disp_comments, + $use_defer_for_loggedin_disp_visits, + $use_defer_for_loggedin_disp_messages, + $use_defer_for_loggedin_disp_threads, + $use_defer_for_loggedin_disp_users, + $use_defer_for_loggedin_disp_contacts, + $use_defer_for_default_register_form; + + $r = $use_defer + && ( is_admin_page() ? $use_defer_for_backoffice : true ) + && ( is_logged_in() ? $use_defer_for_loggedin_users : $use_defer_for_anonymous_users ) + && ( $disp == 'register' ? $use_defer_for_anonymous_disp_register : true ) + && ( $disp == 'register_finish' ? $use_defer_for_anonymous_disp_register_finish : true ) + && ( $disp == 'users' ? $use_defer_for_anonymous_disp_users : true ) + && ( $disp == 'anonpost' ? $use_defer_for_anonymous_disp_anonpost : true ) + && ( empty( $disp ) && $ReqPath == '/htsrv/register.php' ? $use_defer_for_default_register_form : true ) + && ( is_logged_in() && in_array( $disp, array( 'single', 'page' ) ) ? $use_defer_for_loggedin_disp_single_page : true ) + && ( is_logged_in() && $disp == 'front' ? $use_defer_for_loggedin_disp_front : true ) + && ( is_logged_in() && $disp == 'profile' ? $use_defer_for_loggedin_disp_profile : true ) + && ( is_logged_in() && $disp == 'pwdchange' ? $use_defer_for_loggedin_disp_pwdchange : true ) + && ( is_logged_in() && $disp == 'edit' ? $use_defer_for_loggedin_disp_edit : true ) + && ( is_logged_in() && $disp == 'proposechange' ? $use_defer_for_loggedin_disp_proposechange : true ) + && ( is_logged_in() && $disp == 'edit_comment' ? $use_defer_for_loggedin_disp_edit_comment : true ) + && ( is_logged_in() && $disp == 'comments' ? $use_defer_for_loggedin_disp_comments : true ) + && ( is_logged_in() && $disp == 'visits' ? $use_defer_for_loggedin_disp_visits : true ) + && ( is_logged_in() && $disp == 'messages' ? $use_defer_for_loggedin_disp_messages : true ) + && ( is_logged_in() && $disp == 'threads' ? $use_defer_for_loggedin_disp_threads : true ) + && ( is_logged_in() && $disp == 'users' ? $use_defer_for_loggedin_disp_users : true ) + && ( is_logged_in() && $disp == 'contacts' ? $use_defer_for_loggedin_disp_contacts : true ); + + return $r; +} + + +/** + * Get rendering error + * + * @param string Error message + * @param string HTML tag:

    , ,

    + * @return string + */ +function get_rendering_error( $error_message, $html_tag = 'p' ) +{ + if( ! in_array( $html_tag, array( 'p', 'span', 'div' ) ) ) + { // Force not allowed html tag: + $html_tag = 'p'; + } + + return '<'.$html_tag.' class="evo_rendering_error">'.$error_message.''; +} + + +/** + * Display rendering error + * + * @param string Error message + * @param string HTML tag:

    , ,

    + */ +function display_rendering_error( $error_message, $html_tag = 'p' ) +{ + echo get_rendering_error( $error_message, $html_tag ); +} + + +/** + * Clean up rendering errors `

    ...

    ` from provided content + * + * @param string Content with rendering error + * @return string Content without rendering error + */ +function clear_rendering_errors( $content ) +{ + return preg_replace( '#<([a-z]+) class="evo_rendering_error">.+?#', '', $content ); +} +?> \ No newline at end of file diff --git a/inc/_core/_param.funcs.php b/inc/_core/_param.funcs.php index 2958384f3ca..a111ef9c7d4 100644 --- a/inc/_core/_param.funcs.php +++ b/inc/_core/_param.funcs.php @@ -163,7 +163,7 @@ function param_format( $value, $type = 'raw' ) * 'allow_empty' will refuse illegal values but will always accept empty values (This helps blocking dirty spambots or borked index bots. Saves a lot of processor time by killing invalid requests) * @return mixed Final value of Variable, or false if we don't force setting and did not set */ -function param( $var, $type = 'raw', $default = '', $memorize = false, +function param( $var, $type, $default = '', $memorize = false, $override = false, $use_default = true, $strict_typing = 'allow_empty' ) { global $Debuglog, $debug, $evo_charset, $io_charset, $is_cli; @@ -536,7 +536,8 @@ function param( $var, $type = 'raw', $default = '', $memorize = false, * STEP 3: memorize the value for later url regeneration */ if( $memorize === true || - ( $memorize === 'auto' && ( isset( $_POST[$var] ) || isset( $_GET[$var] ) || isset( $_COOKIE[$var] ) ) ) ) + ( $memorize === 'auto' && ( isset( $_POST[$var] ) || isset( $_GET[$var] ) || isset( $_COOKIE[$var] ) ) ) || + ( $memorize === 'ifnotyet' && ! param_ismemorized( $var ) ) ) { // Memorize this parameter: memorize_param( $var, $type, $default ); } @@ -2373,7 +2374,6 @@ function param_check_gender( $var, $required = false ) { if( empty( $GLOBALS[$var] ) ) { // empty is OK if not required: - global $current_User; if( $required ) { param_error( $var, T_( 'Please select a gender.' ) ); diff --git a/inc/_core/_template.funcs.php b/inc/_core/_template.funcs.php index 2aa9856b2c5..bef9dfb3603 100644 --- a/inc/_core/_template.funcs.php +++ b/inc/_core/_template.funcs.php @@ -189,7 +189,7 @@ function header_redirect( $redirect_to = NULL, $status = false, $redirected_post */ global $Hit; global $baseurl, $Collection, $Blog, $htsrv_url, $ReqHost, $ReqURL, $dispatcher; - global $Session, $Debuglog, $Messages; + global $Session, $Debuglog, $Messages, $debug; global $http_response_code, $allow_redirects_to_different_domain; if( empty( $redirect_to ) ) @@ -197,6 +197,9 @@ function header_redirect( $redirect_to = NULL, $status = false, $redirected_post $redirect_to = get_returnto_url(); } + // Keep ONLY allowed params from current URL by config: + $redirect_to = url_keep_params( $redirect_to ); + $Debuglog->add('Preparing to redirect to: '.$redirect_to, 'request' ); // Determine if this is an external or internal redirect: @@ -282,8 +285,6 @@ function header_redirect( $redirect_to = NULL, $status = false, $redirected_post if( ! empty($Session) ) { // Session is required here - - global $debug; if( ! empty( $debug ) ) { // Transfer full debug info to next page only when debug is enabled: ob_start(); @@ -331,6 +332,13 @@ function header_redirect( $redirect_to = NULL, $status = false, $redirected_post header_http_response( '302 Found' ); } + if( $debug && + ! empty( $ReqHost ) && + strpos( $redirect_to, $ReqHost ) !== 0 ) + { // Append param to redirect from different domain in order to see debug info of the current page after redirect: + $redirect_to = url_add_param( $redirect_to, 'get_redirected_debuginfo_from_sess_ID='.$Session->ID, '&' ); + } + // debug_die($redirect_to); if( headers_sent($filename, $line) ) { @@ -479,7 +487,7 @@ function header_etag( $etag ) */ function get_request_title( $params = array() ) { - global $MainList, $preview, $disp, $action, $current_User, $Collection, $Blog, $admin_url; + global $MainList, $preview, $disp, $action, $Collection, $Blog, $admin_url; $r = array(); @@ -494,6 +502,9 @@ function get_request_title( $params = array() ) 'title_page_disp' => true, 'title_page_before' => '#', 'title_page_after' => '#', + 'title_widget_page_disp' => false, // We never want a title to be automatically displayed on a widget page. + 'title_widget_page_before' => '#', + 'title_widget_page_after' => '#', 'title_terms_disp' => true, 'title_terms_before' => '#', 'title_terms_after' => '#', @@ -732,6 +743,7 @@ function get_request_title( $params = array() ) case 'single': case 'page': + case 'widget_page': case 'terms': // We are displaying a single message: if( $preview ) @@ -838,7 +850,7 @@ function get_request_title( $params = array() ) } $title .= $params['edit_links_template']['before']; - if( $current_User->check_perm( 'admin', 'restricted' ) ) + if( check_user_perm( 'admin', 'restricted' ) ) { global $advanced_edit_link; $title .= action_icon( T_('Go to advanced edit screen'), 'edit', $advanced_edit_link['href'], ' '.T_('Advanced editing'), NULL, 3, array( @@ -873,7 +885,7 @@ function get_request_title( $params = array() ) ), $params['edit_links_template'] ); $title .= $params['edit_links_template']['before']; - if( $current_User->check_perm( 'admin', 'restricted' ) ) + if( check_user_perm( 'admin', 'restricted' ) ) { $advanced_edit_url = url_add_param( $admin_url, 'ctrl=comments&action=edit&blog='.$Blog->ID.'&comment_ID='.$edited_Comment->ID ); $title .= action_icon( T_('Go to advanced edit screen'), 'edit', $advanced_edit_url, ' '.T_('Advanced editing'), NULL, 3, array( @@ -1081,11 +1093,77 @@ function blog_home_link( $before = '', $after = '', $blog_text = 'Blog', $home_t } +/** + * Expose PHP variable to JS variable in order to print out them into "; +} + + /** * Get library url of JS or CSS file by file name or alias * * @param string File or Alias name - * @param boolean|string 'relative' or true (relative to ) or 'rsc_url' (relative to $rsc_url) or 'blog' (relative to current blog URL -- may be subdomain or custom domain) + * @param boolean|string 'relative' or true (relative to ), + * 'absolute'(for absolute url) + * 'rsc_url' (relative to $rsc_url), + * 'blog' (relative to current blog URL -- may be subdomain or custom domain) * @param string 'js' or 'css' or 'build' * @return string URL * @param string version number to append at the end of requested url to avoid getting an old version from the cache @@ -1125,12 +1203,20 @@ function get_require_url( $lib_file, $relative_to = 'rsc_url', $subfolder = 'js' } } + if( strpos( $lib_file, 'ext:' ) === 0 || strpos( $lib_file, 'customized:' ) === 0 ) + { // This file must be loaded from subfolder '/rsc/ext/' or '/rsc/customized/' : + $subfolder = strpos( $lib_file, 'ext:' ) === 0 ? 'ext' : 'customized'; + // Remove prefix 'ext:' from beginning of the file: + $lib_file = substr( $lib_file, strlen( $subfolder ) + 1 ); + } + if( $relative_to === 'relative' || $relative_to === true ) { // Make the file relative to current page : $lib_url = $lib_file; } - elseif( preg_match( '~^(https?:)?//~', $lib_file ) ) - { // It's already an absolute url, keep it as is: + elseif( $relative_to === 'absolute' || preg_match( '~^(https?:)?//~', $lib_file ) ) + { // It's already an absolute url, keep it as is: + // (used to require CSS and JS files from Skin and Plugin because there we always use absolute URLs) $lib_url = $lib_file; } elseif( $relative_to === 'blog' && ! empty( $Blog ) ) @@ -1188,6 +1274,56 @@ function get_require_url( $lib_file, $relative_to = 'rsc_url', $subfolder = 'js' return $lib_url; } + +/** + * Check if the requested file is bundled in another + * + * @param string alias, url or filename (relative to rsc/js) for javascript file + * @param boolean|string Is the file's path relative to the base path/url? + * @param string 'js' or 'css' or 'build' + * @param string version number to append at the end of requested url to avoid getting an old version from the cache + * @return integer Index of first file that was dequeued because it is bundled inside current requested file + */ +function check_bundled_file( $file, $relative_to = 'rsc_url', $subfolder = 'js', $version = '#' ) +{ + global $required_js, $required_css, $bundled_files; + + // Store here index of first file that was dequeued because it is bundled inside current requested file: + $first_dequeued_file_index = NULL; + + if( isset( $bundled_files[ $file ] ) ) + { // If currently required file contains other JS files which must not be required twice: + foreach( $bundled_files[ $file ] as $bundled_file ) + { // Include all bundled files in the global array in order to don't call them twice: + $bundled_url = strtolower( get_require_url( $bundled_file, $relative_to, $subfolder, $version ) ); + if( $subfolder == 'js' ) + { // JS file: + if( empty( $required_js ) || ! in_array( $bundled_url, $required_js ) ) + { // Include bundled file into this global array in order to don't require this if it will be required further: + $required_js[] = $bundled_url; + } + } + else // 'css' or 'build' + { // CSS file: + if( empty( $required_css ) || ! in_array( $bundled_url, $required_css ) ) + { // Include bundled file into this global array in order to don't require this if it will be required further: + $required_css[] = $bundled_url; + } + } + // Dequeue the file if it was required before: + $dequeued_file_index = dequeue( $bundled_file, $relative_to ); + if( $first_dequeued_file_index === NULL ) + { // We need to know first dequeued file in order to insert currently + // required file in that place instead of insert it as last ordered: + $first_dequeued_file_index = $dequeued_file_index; + } + } + } + + return $first_dequeued_file_index; +} + + /** * Memorize that a specific javascript file will be required by the current page. * All requested files will be included in the page head only once (when headlines is called) @@ -1198,30 +1334,36 @@ function get_require_url( $lib_file, $relative_to = 'rsc_url', $subfolder = 'js' * * @param string alias, url or filename (relative to rsc/js) for javascript file * @param boolean|string Is the file's path relative to the base path/url? - * @param boolean TRUE to add attribute "async" to load javascript asynchronously + * @param boolean 'async' or TRUE to add attribute "async" to load javascript asynchronously, + * 'defer' to add attribute "defer" asynchronously in the order they occur in the page, + * 'immediate' or FALSE to load javascript immediately * @param boolean TRUE to print script tag on the page, FALSE to store in array to print then inside * @param string version number to append at the end of requested url to avoid getting an old version from the cache + * @param string Position where the CSS files will be inserted, either 'headlines' (inside ) or 'footerlines' (before ) */ -function require_js( $js_file, $relative_to = 'rsc_url', $async = false, $output = false, $version = '#' ) +function require_js( $js_file, $relative_to = 'rsc_url', $async_defer = false, $output = false, $version = '#', $position = 'headlines' ) { - global $required_js; // Use this var as global and NOT static, because it is used in other functions(e.g. display_ajax_form()) - global $dequeued_headlines; + global $required_js; // Use this var as global and NOT static, because it is used in other functions(e.g. display_ajax_form(), check_bundled_file()) + global $use_defer; - if( isset( $dequeued_headlines[ $js_file ] ) ) - { // Don't require this file if it was dequeued before this request + if( is_admin_page() && in_array( $js_file, array( 'functions.js', 'ajax.js', 'form_extensions.js', 'extracats.js', 'dynamic_select.js', 'backoffice.js' ) ) ) + { // Don't require this file on back-office because it is auto loaded by bundled file evo_backoffice.bmin.js: return; } - if( is_admin_page() && in_array( $js_file, array( 'functions.js', 'ajax.js', 'form_extensions.js', 'extracats.js', 'dynamic_select.js', 'backoffice.js' ) ) ) - { // Don't require this file on back-office because it is auto loaded by bundled file evo_backoffice.bmin.js: + if( is_dequeued( $js_file, $relative_to ) ) + { // Don't require if the file was already dequeued once: return; } + // Get index of first file that was dequeued because it is bundled inside current requested file: + $first_dequeued_file_index = check_bundled_file( $js_file, $relative_to, 'js', $version ); + if( in_array( $js_file, array( '#jqueryUI#', 'communication.js', 'functions.js' ) ) ) { // Dependency : ensure jQuery is loaded // Don't use TRUE for $async and $output because it may loads jQuery twice on AJAX request, e.g. on comment AJAX form, // and all jQuery UI libraries(like resizable, sortable and etc.) will not work, e.g. on attachments fieldset - require_js( '#jquery#', $relative_to, false, false, $version ); + require_js_defer( '#jquery#', $relative_to, false, $version, $position ); } // Get library url of JS file by alias name @@ -1233,7 +1375,15 @@ function require_js( $js_file, $relative_to = 'rsc_url', $async = false, $output $required_js[] = strtolower( $js_url ); $script_tag = ''; $script_tag .= ''; @@ -1243,7 +1393,14 @@ function require_js( $js_file, $relative_to = 'rsc_url', $async = false, $output } else { // Add script tag to - add_headline( $script_tag, $js_file, $relative_to ); + if( $position == 'headlines' ) + { + add_headline( $script_tag, $js_file, $relative_to, $first_dequeued_file_index ); + } + elseif( $position == 'footerlines' ) + { + add_footerline( $script_tag, $js_file, $relative_to, $first_dequeued_file_index ); + } } } @@ -1251,11 +1408,41 @@ function require_js( $js_file, $relative_to = 'rsc_url', $async = false, $output * But we should don't forget it for CDN jQuery file and when js code uses deprecated things of jQuery */ if( $js_file == '#jquery#' ) { // Dependency : The plugin restores deprecated features and behaviors so that older code will still run properly on jQuery 1.9 and later - require_js( '#jquery_migrate#', $relative_to, $async, $output, $version ); + require_js_defer( '#jquery_migrate#', $relative_to, $output, $version ); } } +/** + * Require javascript file to load asynchronously with attribute "async" + * + * @param string Alias, url or filename (relative to rsc/js) for javascript file + * @param boolean|string Is the file's path relative to the base path/url? + * @param boolean TRUE to print script tag on the page, FALSE to store in array to print then inside + * @param string Version number to append at the end of requested url to avoid getting an old version from the cache + * @param string Position where the CSS files will be inserted, either 'headlines' (inside ) or 'footerlines' (before ) + */ +function require_js_async( $js_file, $relative_to = 'rsc_url', $output = false, $version = '#', $position = 'headlines' ) +{ + require_js( $js_file, $relative_to, 'async', $output, $version, $position ); +} + + +/** + * Require javascript file to load asynchronously with attribute "defer" in the order they occur in the page + * + * @param string Alias, url or filename (relative to rsc/js) for javascript file + * @param boolean|string Is the file's path relative to the base path/url? + * @param boolean TRUE to print script tag on the page, FALSE to store in array to print then inside + * @param string Version number to append at the end of requested url to avoid getting an old version from the cache + * @param string Position where the CSS files will be inserted, either 'headlines' (inside ) or 'footerlines' (before ) + */ +function require_js_defer( $js_file, $relative_to = 'rsc_url', $output = false, $version = '#', $position = 'headlines' ) +{ + require_js( $js_file, $relative_to, 'defer', $output, $version, $position ); +} + + /** * Memorize that a specific css that file will be required by the current page. * All requested files will be included in the page head only once (when headlines is called) @@ -1268,17 +1455,13 @@ function require_js( $js_file, $relative_to = 'rsc_url', $async = false, $output * @param string title. The title for the link tag * @param string media. ie, 'print' * @param string version number to append at the end of requested url to avoid getting an old version from the cache - * @param boolean TRUE to print style tag on the page, FALSE to store in array to print then inside + * @param boolean TRUE to print style tag on the page, FALSE to store in array to print then inside or + * @param string Position where the CSS files will be inserted, either 'headlines' (inside ) or 'footerlines' (before ) + * @param boolean TRUE to load CSS file asynchronously, FALSE otherwise. */ -function require_css( $css_file, $relative_to = 'rsc_url', $title = NULL, $media = NULL, $version = '#', $output = false ) +function require_css( $css_file, $relative_to = 'rsc_url', $title = NULL, $media = NULL, $version = '#', $output = false, $position = 'headlines', $async = false ) { - static $required_css; - global $dequeued_headlines; - - if( isset( $dequeued_headlines[ $css_file ] ) ) - { // Don't require this file if it was dequeued before this request - return; - } + global $required_css; // Use this var as global and NOT static, because it is used in other functions(e.g. check_bundled_file()) // Which subfolder do we want to use in case of absolute paths? (doesn't appy to 'relative') $subfolder = 'css'; @@ -1290,72 +1473,201 @@ function require_css( $css_file, $relative_to = 'rsc_url', $title = NULL, $media } } + if( is_dequeued( $css_file, $relative_to ) ) + { // Don't require if the file was already dequeued once: + return; + } + + // Get index of first file that was dequeued because it is bundled inside current requested file: + $first_dequeued_file_index = check_bundled_file( $css_file, $relative_to, $subfolder, $version ); + // Get library url of CSS file by alias name $css_url = get_require_url( $css_file, $relative_to, $subfolder, $version ); - // Add to headlines, if not done already: + // Add to headlines/footerlines, if not done already: if( empty( $required_css ) || ! in_array( strtolower( $css_url ), $required_css ) ) { $required_css[] = strtolower( $css_url ); - $stylesheet_tag = ''; + $stylesheet_tag .= ''; + } + if( $output ) - { // Print stylesheet tag right here + { // Print stylesheet tag right here echo $stylesheet_tag; } else - { // Add stylesheet tag to - add_headline( $stylesheet_tag, $css_file, $relative_to ); + { // Add stylesheet tag to + if($position == 'headlines' ) + { + add_headline( $stylesheet_tag, $css_file, $relative_to, $first_dequeued_file_index ); + } + elseif( $position == 'footerlines' ) + { + add_footerline( $stylesheet_tag, $css_file, $relative_to, $first_dequeued_file_index ); + } } } } /** - * Dequeue a file from $headlines array by file name or alias + * Require CSS file to load asynchronously + * + * @param string Alias, url or filename (relative to rsc/css) for CSS file + * @param boolean|string Is the file's path relative to the base path/url? + * @param string title. The title for the link tag + * @param string media. ie, 'print' + * @param string Version number to append at the end of requested url to avoid getting an old version from the cache + * @param boolean TRUE to print script tag on the page, FALSE to store in array to print then inside or + * @param string Position where the CSS files will be inserted, either 'headlines' (inside ) or 'footerlines' (before ) + */ +function require_css_async( $css_file, $relative_to = 'rsc_url', $title = NULL, $media = NULL, $version = '#', $output = false, $position = 'headlines' ) +{ + require_css( $css_file, $relative_to, $title, $media, $version, $output, $position, true ); +} + + +/** + * Dequeue a file from $headlines and $footerlines array by file name or alias * * @param string alias, url or filename (relative to rsc/js) for javascript file - * @param boolean|string What group of headlines touch to dequeue + * @param boolean|string What group of headlines/footerlines touch to dequeue + * @return integer|NULL Index/order of the file in global array on required files, NULL - if the file was not found */ function dequeue( $file_name, $group_relative_to = '#anygroup#' ) { - global $headlines, $dequeued_headlines; + global $headline_include_file, $headline_file_index, $dequeued_headlines; - if( ! is_array( $dequeued_headlines ) ) - { // Initialize array first time: - $dequeued_headlines = array(); + if( is_dequeued( $file_name, $group_relative_to ) ) + { // Don't dequeue twice: + pre_dump( 'is_dequeued' ); + return NULL; } // Convert boolean, NULL and etc. values to string format: $group_relative_to = strval( $group_relative_to ); + if( ! is_array( $dequeued_headlines ) ) + { // Initialize array first time: + $dequeued_headlines = array(); + } + // Store each dequeued file in order to don't require this next time: $dequeued_headlines[ $group_relative_to ][ $file_name ] = true; - if( $group_relative_to == '#anygroup#' ) - { // Dequeue the file from any group: - if( $headlines ) - { - foreach( $headlines as $group_key => $group_headlines ) + // Find and store here index/order of first file: + $dequeued_file_index = NULL; + + // Try to find and dequeue headline file: + if( ! empty( $headline_file_index ) ) + { + $headline_file_indexes = ( $group_relative_to == '#anygroup#' ? $headline_file_index : array() ); + if( $group_relative_to == '#anygroup#' ) + { // Dequeue the file from any group: + $headline_file_indexes = $headline_file_index; + } + elseif( isset( $headline_file_index[ $group_relative_to ] ) ) + { // Dequeue the file only from the requested group: + $headline_file_indexes = array( $group_relative_to => $headline_file_index[ $group_relative_to ] ); + } + if( ! empty( $headline_file_indexes ) ) + { // If relative_to group is found: + foreach( $headline_file_indexes as $group_key => $group_headlines ) { if( isset( $group_headlines[ $file_name ] ) ) - { // Dequeue this file: - unset( $headlines[ $group_key ][ $file_name ] ); + { // Dequeue html/include tag with src/href of the file: + $dequeued_file_index = $headline_file_index[ $group_key ][ $file_name ]; + unset( $headline_include_file[ $group_headlines[ $file_name ] ] ); + // Dequeue index/order of the file: + unset( $headline_file_index[ $group_key ][ $file_name ] ); + // Don't find the file in next groups because it must be unique: + return $dequeued_file_index; } } } } - else - { // Dequeue the file only from requested group: - if( isset( $headlines[ $group_relative_to ][ $file_name ] ) ) - { // Dequeue this file: - unset( $headlines[ $group_relative_to ][ $file_name ] ); + + // Footerlines if the files is not found in Headlines above: + global $footerline_include_file, $footerline_file_index, $dequeued_footerlines; + + if( ! is_array( $dequeued_footerlines ) ) + { // Initialize array first time: + $dequeued_footerlines = array(); + } + + // Store each dequeued file in order to don't require this next time: + $dequeued_footerlines[ $group_relative_to ][ $file_name ] = true; + + // Find and store here index/order of first file: + $dequeued_file_index = NULL; + + // Try to find and dequeue footerline file: + if( ! empty( $footerline_file_index ) ) + { // Try to dequeue footerline file: + $footerline_file_indexes = ( $group_relative_to == '#anygroup#' ? $footerline_file_index : array() ); + if( $group_relative_to == '#anygroup#' ) + { // Dequeue the file from any group: + $footerline_file_indexes = $footerline_file_index; + } + elseif( isset( $footerline_file_index[ $group_relative_to ] ) ) + { // Dequeue the file only from the requested group: + $footerline_file_indexes = array( $group_relative_to => $footerline_file_index[ $group_relative_to ] ); + } + if( ! empty( $footerline_file_indexes ) ) + { // If relative_to group is found: + foreach( $footerline_file_indexes as $group_key => $group_footerlines ) + { + if( isset( $group_footerlines[ $file_name ] ) ) + { // Dequeue html/include tag with src/href of the file: + $dequeued_file_index = $footerline_file_index[ $group_key ][ $file_name ]; + unset( $footerline_include_file[ $group_footerlines[ $file_name ] ] ); + // Dequeue index/order of the file: + unset( $footerline_file_index[ $group_key ][ $file_name ] ); + // Don't find the file in next groups because it must be unique: + return $dequeued_file_index; + } + } } } + + return $dequeued_file_index; +} + + +/** + * Check if file was dequeued from required list + * + * @param string Alias, url or relative file path of JS/CSS file + * @param boolean|string Group of file + */ +function is_dequeued( $file_name, $group_relative_to ) +{ + global $dequeued_headlines, $dequeued_footerlines; + + // Convert boolean, NULL and etc. values to string format: + $group_relative_to = strval( $group_relative_to ); + + return isset( $dequeued_headlines[ $group_relative_to ][ $file_name ] ) || + isset( $dequeued_footerlines[ $group_relative_to ][ $file_name ] ); } @@ -1380,8 +1692,8 @@ function require_js_helper( $helper = '', $relative_to = 'rsc_url' ) case 'helper' : // main helper object required global $debug; - require_js( '#jquery#', $relative_to ); // dependency - require_js( 'helper.js', $relative_to ); + require_js_defer( '#jquery#', $relative_to ); // dependency + require_js_defer( 'helper.js', $relative_to ); add_js_headline('jQuery(document).ready(function() { b2evoHelper.Init({ @@ -1395,7 +1707,7 @@ function require_js_helper( $helper = '', $relative_to = 'rsc_url' ) require_js_helper('helper', $relative_to ); // dependency global $dispatcher; - require_js( 'communication.js', $relative_to ); + require_js_defer( 'communication.js', $relative_to ); add_js_headline('jQuery(document).ready(function() { b2evoCommunications.Init({ @@ -1462,31 +1774,22 @@ function require_js_helper( $helper = '', $relative_to = 'rsc_url' ) $colorbox_params_user = 'var b2evo_colorbox_params_user = '.$colorbox_no_voting_params; } - require_js( '#jquery#', $relative_to ); + require_js_defer( '#jquery#', $relative_to ); // Initialize the colorbox settings: - add_js_headline( - // General settings: - 'var b2evo_colorbox_params = { - maxWidth: jQuery( window ).width() > 480 ? "95%" : "100%", - maxHeight: jQuery( window ).height() > 480 ? "90%" : "100%", - slideshow: true, - slideshowAuto: false - }; - '// For post images - .$colorbox_params_post.'; - b2evo_colorbox_params_post = jQuery.extend( {}, b2evo_colorbox_params, b2evo_colorbox_params_post ); + add_js_footerline( + // For post images + $colorbox_params_post.'; '// For comment images .$colorbox_params_cmnt.'; - b2evo_colorbox_params_cmnt = jQuery.extend( {}, b2evo_colorbox_params, b2evo_colorbox_params_cmnt ); '// For user images .$colorbox_params_user.'; - b2evo_colorbox_params_user = jQuery.extend( {}, b2evo_colorbox_params, b2evo_colorbox_params_user ); '// For all other images - .$colorbox_params_other.'; - b2evo_colorbox_params = jQuery.extend( {}, b2evo_colorbox_params, b2evo_colorbox_params_other );' ); + .$colorbox_params_other.';' ); // TODO: translation strings for colorbox buttons - require_js( 'build/colorbox.bmin.js', $relative_to, true ); + // Do NOT require colorbox.bmin.js here because it is grunted in evo_generic.bmin.js: + // require_js_defer( 'build/colorbox.bmin.js', $relative_to ); + if( is_admin_page() ) { global $AdminUI; @@ -1531,33 +1834,87 @@ function add_js_translation( $string, $translation ) /** * Add a headline, which then gets output in the HTML HEAD section. * If you want to include CSS or JavaScript files, please use - * {@link require_css()} and {@link require_js()} instead. + * {@link require_css()} and {@link require_js_async()} and {@link require_js_defer()} instead. * This avoids duplicates and allows caching/concatenating those files * later (not implemented yet) * * @param string HTML tag like or * @param string File name (used to index) * @param boolean|string Group headlines by this group in order to allow use files with same names from several places + * @param integer Insert new headline in the given index, Useful to insert superbundled file instead of first bundled file */ -function add_headline( $headline, $file_name = NULL, $group_relative_to = '#nogroup#' ) +function add_headline( $headline, $file_name = NULL, $group_relative_to = '#nogroup#', $file_index = NULL ) { - global $headlines, $dequeued_headlines; + if( $file_name === NULL ) + { // Add inline code: + global $headline_inline_code; + $headline_inline_code[] = $headline; + } + else + { // Add include file: + global $headline_include_file, $headline_file_index; + // Convert boolean, NULL and etc. values to string format: + $group_relative_to = strval( $group_relative_to ); + if( isset( $headline_file_index[ $group_relative_to ][ $file_name ] ) ) + { // Skip already included file from the same group: + return; + } + if( $file_index === NULL || isset( $headline_include_file[ $file_index ] ) ) + { // Use auto order/index: + $headline_include_file[] = $headline; + $file_index = max( array_keys( $headline_include_file ) ); + } + else + { // Use specific order/index when it is requested and the index is free: + $headline_include_file[ $file_index ] = $headline; + } + // Flag to don't include same file from same group twice, + // Also store value as index/order in order to dequeue it quickly: + $headline_file_index[ $group_relative_to ][ $file_name ] = $file_index; + } +} - // Convert boolean, NULL and etc. values to string format: - $group_relative_to = strval( $group_relative_to ); - if( is_null( $file_name ) ) - { // Use auto index if file name is not defined: - $headlines[ $group_relative_to ][] = $headline; +/** + * Add a footerline, which then gets output before the tag. + * If you want to include CSS or JavaScript files, please use + * {@link require_css()} and {@link require_js_async()} and {@link require_js_defer()} instead. + * This avoids duplicates and allows caching/concatenating those files + * later (not implemented yet) + * + * @param string HTML tag like or + * @param string File name (used to index) + * @param boolean|string Group footerlines by this group in order to allow use files with same names from several places + * @param integer Insert new headline in the given index, Useful to insert superbundled file instead of first bundled file + */ +function add_footerline( $footerline, $file_name = NULL, $group_relative_to = '#nogroup#', $file_index = NULL ) +{ + if( $file_name === NULL ) + { // Add inline code: + global $footerline_inline_code; + $footerline_inline_code[] = $footerline; } else - { // Try to add headline with file name to array: - if( isset( $dequeued_headlines[ $group_relative_to ][ $file_name ] ) || isset( $dequeued_headlines[ '#anygroup#' ][ $file_name ] ) ) - { // Don't require this file if it was dequeued before this request: + { // Add include file: + global $footerline_include_file, $footerline_file_index; + // Convert boolean, NULL and etc. values to string format: + $group_relative_to = strval( $group_relative_to ); + if( isset( $footerline_file_index[ $group_relative_to ][ $file_name ] ) ) + { // Skip already included file from the same group: return; } - // Use file name as key index in $headline array: - $headlines[ $group_relative_to ][ $file_name ] = $headline; + if( $file_index === NULL || isset( $footerline_include_file[ $file_index ] ) ) + { // Use auto order/index: + $footerline_include_file[] = $footerline; + $file_index = max( array_keys( $footerline_include_file ) ); + } + else + { // Use specific order/index when it is requested and the index is free: + $footerline_include_file[ $file_index ] = $footerline; + } + // Flag to don't include same file from same group twice, + // Also store value as index/order in order to dequeue it quickly: + $footerline_file_index[ $group_relative_to ][ $file_name ] = $file_index; } } @@ -1576,6 +1933,20 @@ function add_js_headline($headline) } +/** + * Add a Javascript footerline. + * This is an extra function, to provide consistent wrapping and allow to bundle it + * (i.e. create a bundle with all required JS files and these inline code snippets, + * in the correct order). + * @param string Javascript + */ +function add_js_footerline($footerline) +{ + add_footerline(""); +} + + /** * Add a CSS headline. * This is an extra function, to provide consistent wrapping and allow to bundle it @@ -1589,6 +1960,19 @@ function add_css_headline($headline) } +/** + * Add a CSS footerline. + * This is an extra function, to provide consistent wrapping and allow to bundle it + * (i.e. create a bundle with all required CSS code snippets, + * in the correct order). + * @param string CSS + */ +function add_css_footerline($footerline) +{ + add_footerline(""); +} + + /** * Registers all the javascripts needed by the toolbar menu * @@ -1611,7 +1995,7 @@ function init_ajax_forms( $relative_to = 'blog' ) if( !empty($Blog) && $Blog->get_setting('ajax_form_enabled') ) { - require_js( 'communication.js', $relative_to ); + require_js_defer( 'communication.js', $relative_to ); }*/ } @@ -1626,8 +2010,9 @@ function init_ratings_js( $relative_to = 'blog', $force_init = false ) // fp> Note, the following test is good for $disp == 'single', not for 'posts' if( $force_init || ( !empty($Item) && $Item->can_rate() ) ) { - require_js( '#jquery#', $relative_to ); // dependency - require_js( 'jquery/jquery.raty.min.js', $relative_to ); + require_js_defer( '#jquery#', $relative_to ); // dependency + require_js_defer( 'customized:jquery/raty/jquery.raty.min.js', $relative_to ); + require_js_defer( 'src/evo_init_comment_rating.js', $relative_to ); } } @@ -1645,21 +2030,21 @@ function init_bubbletip_js( $relative_to = 'rsc_url', $library = 'bubbletip' ) return; } - require_js( '#jquery#', $relative_to ); + require_js_defer( '#jquery#', $relative_to ); switch( $library ) { case 'popover': // Use popover library of bootstrap - require_js( 'build/popover.bmin.js', $relative_to, true ); + require_js_defer( 'build/popover.bmin.js', $relative_to ); break; case 'bubbletip': default: // Use bubbletip plugin of jQuery - require_js( 'jquery/jquery.bubbletip.min.js', $relative_to ); - require_js( 'build/bubbletip.bmin.js', $relative_to, true ); - require_css( 'jquery/jquery.bubbletip.css', $relative_to ); + require_js_defer( 'customized:jquery/bubbletip/js/jquery.bubbletip.min.js', $relative_to ); + require_js_defer( 'build/bubbletip.bmin.js', $relative_to ); + require_css( 'customized:jquery/bubbletip/css/jquery.bubbletip.css', $relative_to ); break; } } @@ -1674,22 +2059,22 @@ function init_bubbletip_js( $relative_to = 'rsc_url', $library = 'bubbletip' ) function init_userfields_js( $relative_to = 'rsc_url', $library = 'bubbletip' ) { // Load to autocomplete user fields with list type - require_js( '#jqueryUI#', $relative_to ); + require_js_defer( '#jqueryUI#', $relative_to ); require_css( '#jqueryUI_css#', $relative_to ); switch( $library ) { case 'popover': // Use popover library of bootstrap - require_js( 'build/popover.bmin.js', $relative_to, true ); + require_js_defer( 'build/popover.bmin.js', $relative_to ); break; case 'bubbletip': default: // Use bubbletip plugin of jQuery - require_js( 'jquery/jquery.bubbletip.min.js', $relative_to ); - require_js( 'build/bubbletip.bmin.js', $relative_to, true ); - require_css( 'jquery/jquery.bubbletip.css', $relative_to ); + require_js_defer( 'customized:jquery/bubbletip/js/jquery.bubbletip.min.js', $relative_to ); + require_js_defer( 'build/bubbletip.bmin.js', $relative_to ); + require_css( 'customized:jquery/bubbletip/css/jquery.bubbletip.css', $relative_to ); break; } } @@ -1717,21 +2102,21 @@ function init_plugins_js( $relative_to = 'rsc_url', $library = 'bubbletip' ) */ function init_popover_js( $relative_to = 'rsc_url', $library = 'bubbletip' ) { - require_js( '#jquery#', $relative_to ); + require_js_defer( '#jquery#', $relative_to ); switch( $library ) { case 'popover': // Use popover library of bootstrap - require_js( 'build/popover.bmin.js', $relative_to, true ); + require_js_defer( 'build/popover.bmin.js', $relative_to ); break; case 'bubbletip': default: // Use bubbletip plugin of jQuery - require_js( 'jquery/jquery.bubbletip.min.js', $relative_to ); - require_js( 'build/bubbletip.bmin.js', $relative_to, true ); - require_css( 'jquery/jquery.bubbletip.css', $relative_to ); + require_js_defer( 'customized:jquery/bubbletip/js/jquery.bubbletip.min.js', $relative_to ); + require_js_defer( 'build/bubbletip.bmin.js', $relative_to ); + require_css( 'customized:jquery/bubbletip/css/jquery.bubbletip.css', $relative_to ); break; } } @@ -1742,17 +2127,18 @@ function init_popover_js( $relative_to = 'rsc_url', $library = 'bubbletip' ) */ function init_datepicker_js( $relative_to = 'rsc_url' ) { - require_js( '#jqueryUI#', $relative_to ); + require_js_defer( '#jqueryUI#', $relative_to ); require_css( '#jqueryUI_css#', $relative_to ); - add_js_headline( 'jQuery(document).ready( function(){ - jQuery(".form_date_input").datepicker({ - dateFormat: "'.jquery_datepicker_datefmt().'", - monthNames: '.jquery_datepicker_month_names().', - dayNamesMin: '.jquery_datepicker_day_names().', - firstDay: '.locale_startofweek().' - }) - })' ); + // We did not use json_encode here as it will escape the dateFormat: + expose_var_to_js( 'evo_init_datepicker', '{' + .'selector: ".form_date_input",' + .'config: {' + .'dateFormat: "'.jquery_datepicker_datefmt().'",' + .'monthNames: '.jquery_datepicker_month_names().',' + .'dayNamesMin: '.jquery_datepicker_day_names().',' + .'firstDay: '.locale_startofweek().'}' + .'}' ); } @@ -1761,9 +2147,9 @@ function init_datepicker_js( $relative_to = 'rsc_url' ) */ function init_tokeninput_js( $relative_to = 'rsc_url' ) { - require_js( '#jquery#', $relative_to ); // dependency - require_js( 'jquery/jquery.tokeninput.js', $relative_to ); - require_css( 'jquery/jquery.token-input-facebook.css', $relative_to ); + require_js_defer( '#jquery#', $relative_to ); // dependency + require_js_defer( 'customized:jquery/tokeninput/js/jquery.tokeninput.js', $relative_to ); + require_css( 'customized:jquery/tokeninput/css/jquery.token-input-facebook.css', $relative_to ); } @@ -1772,8 +2158,8 @@ function init_tokeninput_js( $relative_to = 'rsc_url' ) */ function init_results_js( $relative_to = 'rsc_url' ) { - require_js( '#jquery#', $relative_to ); // dependency - require_js( 'results.js', $relative_to ); + require_js_defer( '#jquery#', $relative_to ); // dependency + require_js_defer( 'results.js', $relative_to ); } @@ -1800,71 +2186,8 @@ function init_affix_messages_js( $offset = NULL ) $site_header_fixed = $site_Skin->get_setting( 'fixed_header' ) == 1 ? 'true' : 'false'; } - add_js_headline( ' - jQuery( document ).ready( function() - { - var msg_obj = jQuery( ".affixed_messages" ); - - if( msg_obj.length == 0 ) - { // No Messages, exit - return; - } - - var msg_obj_width = msg_obj.outerWidth(); - var msg_offset = '.format_to_js( $offset ).'; - var evo_bar = jQuery( "#evo_toolbar" ); - var site_header = jQuery( "#evo_site_header" ); - var evo_affix_fixed_header = '.format_to_js( $site_header_fixed ).'; - - if( evo_bar.length ) - { // Add evobar height to offset: - msg_offset += evo_bar.outerHeight(); - } - if( evo_affix_fixed_header && site_header.length ) - { // Site header is fixed, add height to offset: - msg_offset += site_header.outerHeight(); - } - - msg_obj.wrap( "
    " ); - var wrapper = msg_obj.parent(); - - msg_obj.affix( { - offset: { - top: function() { - return wrapper.offset().top - msg_offset - parseInt( msg_obj.css( "margin-top" ) ); - } - } - } ); - - msg_obj.on( "affix.bs.affix", function() - { - wrapper.css( { "min-height": msg_obj.outerHeight( true ) } ); - - msg_obj.css( { "width": msg_obj_width, "top": msg_offset, "z-index": 9999 } ); - - jQuery( window ).on( "resize", function() - { // This will resize the Messages based on the wrapper width - msg_obj.css( { "width": wrapper.css( "width" ) } ); - }); - } ); - - msg_obj.on( "affixed-top.bs.affix", function() - { - wrapper.css( { "min-height": "" } ); - msg_obj.css( { "width": "", "top": "", "z-index": "" } ); - } ); - - jQuery( "div.alert", msg_obj ).on( "closed.bs.alert", function() - { - wrapper.css({ "min-height": msg_obj.outerHeight( true ) }); - } ); - - if( msg_obj.hasClass( "affix" ) ) - { // Manually trigger the "affix.bs.affix" event: - msg_obj.trigger( "affix.bs.affix" ); - } - } ); - ' ); + add_js_headline( 'evo_affix_msg_offset = '.format_to_js( $offset ).'; evo_affix_fixed_header = '.format_to_js( $site_header_fixed ).';' ); + require_js_defer( 'src/evo_init_affix_messages.js', 'blog' ); } @@ -1882,18 +2205,18 @@ function init_voting_comment_js( $relative_to = 'rsc_url' ) return false; } - require_js( '#jquery#', $relative_to ); // dependency - require_js( 'voting.js', $relative_to ); - add_js_headline( ' - jQuery( document ).ready( function() - { - var comment_voting_url = "'.get_htsrv_url().'anon_async.php?action=voting&vote_type=comment&b2evo_icons_type='.$b2evo_icons_type.'"; - jQuery( "span[id^=vote_helpful_]" ).each( function() - { - init_voting_bar( jQuery( this ), comment_voting_url, jQuery( this ).find( "#votingID" ).val(), false ); - } ); - } ); - ' ); + require_js_defer( '#jquery#', $relative_to ); // dependency + require_js_defer( 'voting.js', $relative_to ); + + $js_config = array( + 'action_url' => url_add_param( get_htsrv_url().'anon_async.php', array( + 'action' => 'voting', + 'vote_type' => 'comment', + 'b2evo_icons_type' => $b2evo_icons_type + ) ), + ); + + expose_var_to_js( 'evo_init_comment_voting_config', evo_json_encode( $js_config ) ); } @@ -1911,18 +2234,18 @@ function init_voting_item_js( $relative_to = 'rsc_url' ) return false; } - require_js( '#jquery#', $relative_to ); - require_js( 'voting.js', $relative_to ); - add_js_headline( ' - jQuery( document ).ready( function() - { - var item_voting_url = "'.get_htsrv_url().'anon_async.php?action=voting&vote_type=item&b2evo_icons_type='.$b2evo_icons_type.'"; - jQuery( "span[id^=vote_item_]" ).each( function() - { - init_voting_bar( jQuery( this ), item_voting_url, jQuery( this ).find( "#votingID" ).val(), false ); - } ); - } ); - ' ); + require_js_defer( '#jquery#', $relative_to ); + require_js_defer( 'voting.js', $relative_to ); + + $js_config = array( + 'action_url' => url_add_param( get_htsrv_url().'anon_async.php', array( + 'action' => 'voting', + 'vote_type' => 'item', + 'b2evo_icons_type' => $b2evo_icons_type + ) ), + ); + + expose_var_to_js( 'evo_init_item_voting_config', evo_json_encode( $js_config ) ); } @@ -1938,9 +2261,9 @@ function init_colorpicker_js( $relative_to = 'rsc_url' ) global $current_User, $UserSettings; - require_js( '#jquery#', $relative_to ); - require_js( 'bootstrap/colorpicker/bootstrap-colorpicker.min.js', $relative_to ); - require_css( 'bootstrap-colorpicker.min.css', $relative_to ); + require_js_defer( '#jquery#', $relative_to ); + require_js_defer( 'ext:bootstrap/colorpicker/js/bootstrap-colorpicker.min.js', $relative_to ); + require_css( 'ext:bootstrap/colorpicker/css/bootstrap-colorpicker.min.css', $relative_to ); // Get preselected colors from settings of current User: $user_colors = $UserSettings->get( 'colorpicker', $current_User->ID ); @@ -2038,66 +2361,17 @@ function init_autocomplete_login_js( $relative_to = 'rsc_url', $library = 'hintb { global $Collection, $Blog; - require_js( '#jquery#', $relative_to ); // dependency + require_js_defer( '#jquery#', $relative_to ); // dependency switch( $library ) { case 'typeahead': // Use typeahead library of bootstrap - require_js( '#bootstrap_typeahead#', $relative_to ); - add_js_headline( 'jQuery( document ).ready( function() - { - jQuery( "input.autocomplete_login" ).on( "added",function() - { - jQuery( "input.autocomplete_login" ).each( function() - { - if( jQuery( this ).hasClass( "tt-input" ) || jQuery( this ).hasClass( "tt-hint" ) ) - { // Skip this field because typeahead is initialized before: - return; - } - var ajax_url = ""; - if( jQuery( this ).hasClass( "only_assignees" ) ) - { - ajax_url = restapi_url + "'.( isset( $Blog ) ? 'collections/'.$Blog->get( 'urlname' ).'/assignees' : 'users/logins' ).'"; - } - else - { - ajax_url = restapi_url + "users/logins"; - } - if( jQuery( this ).data( "status" ) ) - { - ajax_url += "&status=" + jQuery( this ).data( "status" ); - } - jQuery( this ).typeahead( null, - { - displayKey: "login", - source: function ( query, cb ) - { - jQuery.ajax( - { - type: "GET", - dataType: "JSON", - url: ajax_url, - data: { q: query }, - success: function( data ) - { - var json = new Array(); - for( var l in data.list ) - { - json.push( { login: data.list[ l ] } ); - } - cb( json ); - } - } ); - } - } ); - } ); - } ); - jQuery( "input.autocomplete_login" ).trigger( "added" ); - ' - // Don't submit a form by Enter when user is editing the owner fields - .get_prevent_key_enter_js( 'input.autocomplete_login' ).' - } );' ); + require_js_defer( '#bootstrap_typeahead#', $relative_to ); + expose_var_to_js( 'evo_autocomplete_login_config', '{ + url: "'.( isset( $Blog ) ? 'collections/'.$Blog->get( 'urlname' ).'/assignees' : 'users/logins' ).'", + selector: "input.autocomplete_login", + }' ); break; case 'hintbox': @@ -2109,8 +2383,8 @@ function init_autocomplete_login_js( $relative_to = 'rsc_url', $library = 'hintb // fp> TODO: think about a way to bundle this with other JS on the page -- maybe always load hintbox in the backoffice // dh> Handle it via http://www.appelsiini.net/projects/lazyload ? // dh> TODO: should probably also get ported to use jquery.ui.autocomplete (or its successor) - require_css( 'jquery/jquery.hintbox.css', $relative_to ); - require_js( 'jquery/jquery.hintbox.min.js', $relative_to ); + require_css( 'ext:jquery/hintbox/css/jquery.hintbox.css', $relative_to ); + require_js( 'ext:jquery/hintbox/js/jquery.hintbox.min.js', $relative_to ); add_js_headline( 'jQuery( document ).on( "focus", "input.autocomplete_login", function() { var ajax_url = ""; @@ -2146,21 +2420,15 @@ function init_autocomplete_login_js( $relative_to = 'rsc_url', $library = 'hintb * Registers headlines required to jqPlot charts * * @param string alias, url or filename (relative to rsc/css, rsc/js) for JS/CSS files + * @param boolean TRUE to print script tag on the page, FALSE to store in array to print then inside + * @param string Version number to append at the end of requested url to avoid getting an old version from the cache + * @param string Position where the CSS files will be inserted, either 'headlines' (inside ) or 'footerlines' (before ) */ -function init_jqplot_js( $relative_to = 'rsc_url' ) +function init_jqplot_js( $relative_to = 'rsc_url', $output = false, $version = '#', $position = 'headlines' ) { - require_js( '#jquery#', $relative_to ); // dependency - require_js( '#jqplot#', $relative_to ); - require_js( '#jqplot_barRenderer#', $relative_to ); - require_js( '#jqplot_canvasAxisTickRenderer#', $relative_to ); - require_js( '#jqplot_canvasTextRenderer#', $relative_to ); - require_js( '#jqplot_categoryAxisRenderer#', $relative_to ); - require_js( '#jqplot_enhancedLegendRenderer#', $relative_to ); - require_js( '#jqplot_highlighter#', $relative_to ); - require_js( '#jqplot_canvasOverlay#', $relative_to ); - require_js( '#jqplot_donutRenderer#', $relative_to ); - require_css( '#jqplot_css#', $relative_to ); - require_css( 'jquery/jquery.jqplot.b2evo.css', $relative_to ); + require_js_defer( 'build/evo_jqplot.bmin.js', $relative_to, $output, $version, $position ); + require_js_defer( 'src/evo_init_canvas_bar_chart.js', $relative_to, $output, $version, $position ); + require_css_async( 'b2evo_jqplot.bmin.css', $relative_to, NULL, NULL, $version, $output, $position ); } @@ -2171,24 +2439,24 @@ function init_querybuilder_js( $relative_to = 'rsc_url' ) { global $current_locale; - require_js( '#jquery#', $relative_to ); // dependency + require_js_defer( '#jquery#', $relative_to ); // dependency require_css( '#jqueryUI_css#', $relative_to ); // dependency for date picker - require_js( 'jquery/query-builder/doT.min.js', $relative_to ); // dependency - require_js( 'jquery/query-builder/jquery.extendext.min.js', $relative_to ); // dependency - require_js( 'jquery/query-builder/moment.js', $relative_to ); // dependency + require_js_defer( 'ext:jquery/query-builder/js/doT.min.js', $relative_to ); // dependency + require_js_defer( 'ext:jquery/query-builder/js/jquery.extendext.min.js', $relative_to ); // dependency + require_js_defer( 'ext:jquery/query-builder/js/moment.js', $relative_to ); // dependency - require_js( 'jquery/query-builder/query-builder.min.js', $relative_to ); - require_css( 'jquery/jquery.query-builder.default.css', $relative_to ); + require_js_defer( 'ext:jquery/query-builder/js/query-builder.min.js', $relative_to ); + require_css( 'ext:jquery/query-builder/css/jquery.query-builder.default.css', $relative_to ); // Load language file if such file exists: $query_builder_langs = array( 'ar', 'az', 'bg', 'cs', 'da', 'de', 'el', 'en', 'es', 'fa-IR', 'fr', 'he', 'it', 'nl', 'no', 'pl', 'pt-BR', 'pt-PT', 'ro', 'ru', 'sq', 'tr', 'ua', 'zh-CN' ); if( in_array( $current_locale, $query_builder_langs ) ) { // Load lang by full locale name like "en-US": - require_js( 'jquery/query-builder/i18n/query-builder.'.$current_locale.'.js', $relative_to ); + require_js_defer( 'ext:jquery/query-builder/js/i18n/query-builder.'.$current_locale.'.js', $relative_to ); } elseif( in_array( substr( $current_locale, 0, 2 ), $query_builder_langs ) ) { // Load lang by locale code like "en": - require_js( 'jquery/query-builder/i18n/query-builder.'.substr( $current_locale, 0, 2 ).'.js', $relative_to ); + require_js_defer( 'ext:jquery/query-builder/js/i18n/query-builder.'.substr( $current_locale, 0, 2 ).'.js', $relative_to ); } } @@ -2198,13 +2466,13 @@ function init_querybuilder_js( $relative_to = 'rsc_url' ) */ function init_hotkeys_js( $relative_to = 'rsc_url', $hotkeys = array(), $top_hotkeys = array() ) { - require_js( '#jquery#', $relative_to ); // dependency - require_js( '#hotkeys#', $relative_to ); + require_js_defer( '#jquery#', $relative_to ); // dependency + require_js_defer( '#hotkeys#', $relative_to ); add_js_headline( 'var shortcut_keys = '.json_encode( $hotkeys ).';' ); add_js_headline( 'var top_shortcut_keys = '.json_encode( $top_hotkeys ).';' ); - require_js( 'hotkeys/hotkeys.init.js', $relative_to ); + require_js_defer( 'ext:hotkeys/hotkeys.init.js', $relative_to ); } @@ -2215,31 +2483,26 @@ function init_hotkeys_js( $relative_to = 'rsc_url', $hotkeys = array(), $top_hot */ function include_headlines() { - global $headlines; + global $headline_include_file, $headline_file_index, $headline_inline_code; - if( $headlines ) - { - if( isset( $headlines['#nogroup#'] ) ) - { // Move no group head lines to the end in order to print them after files, - // because Safari and Firefox rewrite css of ' - ); - jQuery( '#p-container' ).css( 'width', pass1input.outerWidth() - 2 ); - var pass1input_marginleft = parseInt( pass1input.css( 'margin-left' ) ); - if( pass1input_marginleft > 0 ) - { - jQuery( '#p-container' ).css( 'margin-left', pass1input_marginleft + 'px' ); - } - } - - function passinfo(el) - { - var presult = document.getElementById('p-result'); - var pstatus = document.getElementById('p-status'); - var ptime = document.getElementById('p-time'); - - var vlogin = ''; - var login = document.getElementById('".$params['login-id']."'); - if( login != null && login.value != '' ) { vlogin = login.value; } - - var vemail = ''; - var email = document.getElementById('".$params['email-id']."'); - if( email != null && email.value != '' ) { vemail = email.value; } - - // Check the password - var passcheck = zxcvbn(el.value, [vlogin, vemail, ".$params['blacklist']."]); - - var bar_color = 'red'; - var bar_status = '".format_to_output( T_('Very weak'), 'htmlattr' )."'; - - if( el.value.length == 0 ) { - presult.style.display = 'none'; - pstatus.style.display = 'none'; - ptime.style.display = 'none'; - } else { - presult.style.display = 'block'; - pstatus.style.display = 'block'; - ptime.style.display = 'block'; - } - - switch(passcheck.score) { - case 1: - bar_color = '#F88158'; - bar_status = '".format_to_output( TS_('Weak'), 'htmlattr' )."'; - break; - case 2: - bar_color = '#FBB917'; - bar_status = '".format_to_output( TS_('So-so'), 'htmlattr' )."'; - break; - case 3: - bar_color = '#8BB381'; - bar_status = '".format_to_output( TS_('Good'), 'htmlattr' )."'; - break; - case 4: - bar_color = '#59E817'; - bar_status = '".format_to_output( TS_('Great!'), 'htmlattr' )."'; - break; - } - - presult.style.width = (passcheck.score * 20 + 20)+'%'; - presult.style.background = bar_color; - - if( ".$params['disp-status']." ) { - pstatus.innerHTML = bar_status; - } - if( ".$params['disp-time']." ) { - document.getElementById('p-time').innerHTML = '".TS_('Estimated crack time').": ' + passcheck.crack_time_display; - } - } - - jQuery( 'input#".$params[ 'pass1-id' ].", input#".$params[ 'pass2-id' ]."' ).keyup( function() - { // Validate passwords - var minLength = ".format_to_js( $Settings->get( 'user_minpwdlen' ) )."; - var pass1Field = jQuery( 'input#".$params[ 'pass1-id' ]."' ); - var pass2Field = jQuery( 'input#".$params[ 'pass2-id' ]."' ); - var passStatus = jQuery( '#pass2_status' ); - var errorMsg = ''; - const regex = /^[^\<\&\>]+$/g; // Password cannot contain the following characters: < > & - - if( ( pass1Field.val().length && ( pass1Field.val().match( regex ) == null ) ) || - ( pass2Field.val().length && ( pass2Field.val().match( regex ) == null ) ) ) - { - errorMsg = '".sprintf( TS_('Password cannot contain the following characters: %s'), '< > &' )."'; - pass1Field[0].setCustomValidity( pass1Field.val().match( regex ) ? '' : errorMsg ); - pass2Field[0].setCustomValidity( pass2Field.val().match( regex ) ? '' : errorMsg ); - passStatus.html( '".get_icon( 'xross' )." ' + errorMsg ); - } - else if( ( pass1Field.val().length > 0 && pass1Field.val().length < minLength ) || ( pass2Field.val().length > 0 && pass2Field.val().length < minLength ) ) - { // Password does not meet minimum length - errorMsg = '".sprintf( TS_('The minimum password length is %d characters.'), $Settings->get( 'user_minpwdlen' ) )."'; - pass1Field[0].setCustomValidity( pass1Field.val().length < minLength ? errorMsg : '' ); - pass2Field[0].setCustomValidity( pass2Field.val().length < minLength ? errorMsg : '' ); - passStatus.html( '".get_icon( 'xross' )." ' + errorMsg ); - } - else if( pass2Field.val() != pass1Field.val() ) - { // Passwords are different - errorMsg = '".TS_('The second password is different from the first.')."'; - pass1Field[0].setCustomValidity( '' ); - pass2Field[0].setCustomValidity( errorMsg ); - passStatus.html( '".get_icon( 'xross' )." ' + errorMsg ); - } - else - { - pass1Field[0].setCustomValidity( errorMsg ); - pass2Field[0].setCustomValidity( errorMsg ); - passStatus.html( errorMsg ); - } - } ); -"; + expose_var_to_js( 'evo_init_password_indicator_config', evo_json_encode( $password_indicator_config ) ); } @@ -3632,110 +3635,12 @@ function display_password_js_edit() { global $Settings; - echo ''; + expose_var_to_js( 'evo_init_password_edit_config', evo_json_encode( $password_edit_config ) ); } @@ -3748,63 +3653,20 @@ function display_login_validator( $params = array() ) { global $rsc_url, $dummy_fields; - $params = array_merge( array( - 'login-id' => $dummy_fields[ 'login' ], - ), $params ); + $login_validator_config = array( + 'login_id' => $dummy_fields[ 'login' ], + 'rsc_url' => $rsc_url, + 'login_htsrv_url' => get_htsrv_url( 'login' ), + 'login_icon_load' => ''.T_('Loading...').'', + 'login_icon_available' => get_icon( 'allowback', 'imgtag', array( 'title' => T_('This username is available.') ) ), + 'login_icon_exists' => get_icon( 'xross', 'imgtag', array( 'title' => T_('This username is already in use. Please choose another one.') ) ), + 'login_icon_error' => get_icon( 'xross', 'imgtag', array( 'title' => '$error_msg$' ) ), + 'login_text_empty' => T_('Choose a username'), + 'login_text_available' => T_('This username is available.'), + 'login_text_exists' => T_('This username is already in use. Please choose another one.'), + ); - echo ''; + expose_var_to_js( 'evo_init_login_validator_config', evo_json_encode( $login_validator_config ) ); } @@ -3824,7 +3686,7 @@ function init_field_editor_js( $params = array() ) 'relative_to' => 'rsc_url', ), $params ); - require_js( '#jquery#', $params['relative_to'] ); // dependency + require_js_defer( '#jquery#', $params['relative_to'] ); // dependency add_js_headline( 'jQuery( document ).on( "click", "[id^='.$params['field_prefix'].']", function() { @@ -3936,12 +3798,12 @@ function init_autocomplete_usernames_js( $relative_to = 'rsc_url' ) { global $Collection, $Blog; - require_js( '#jquery#', $relative_to ); if( ! empty( $Blog ) ) { // Set global blog ID for textcomplete(Used to sort users by collection members and assignees): add_js_headline( 'var blog = '.$Blog->ID ); } - require_js( 'build/textcomplete.bmin.js', $relative_to ); + require_js_defer( '#jquery#', $relative_to ); + require_js_defer( 'build/textcomplete.bmin.js', $relative_to ); } @@ -3969,16 +3831,19 @@ function get_prevent_key_enter_js( $jquery_selection ) * - 'fontawesome' - Use only font-awesome icons * - 'fontawesome-glyphicons' - Use font-awesome icons as a priority over the glyphicons * @param boolean|string 'relative' or true (relative to ) or 'rsc_url' (relative to $rsc_url) or 'blog' (relative to current blog URL -- may be subdomain or custom domain) + * @param boolean TRUE - to require css file, FALSE - is used when css file is already loaded inside superbundle file */ -function init_fontawesome_icons( $icons_type = 'fontawesome', $relative_to = 'rsc_url' ) +function init_fontawesome_icons( $icons_type = 'fontawesome', $relative_to = 'rsc_url', $require_files = true ) { global $b2evo_icons_type; // Use font-awesome icons, @see get_icon() $b2evo_icons_type = $icons_type; - // Load main CSS file of font-awesome icons - require_css( '#fontawesome#', $relative_to ); + if( $require_files ) + { // Load main CSS file of font-awesome icons + require_css( '#fontawesome#', $relative_to ); + } } @@ -4073,17 +3938,21 @@ function get_star_rating( $value, $stars_num = 5, $params = array() ) */ function init_fileuploader_js( $relative_to = 'rsc_url', $load_sortable_js = true ) { - // Require Fine Uploader js and css files: - require_js( 'multiupload/fine-uploader.js', $relative_to ); - require_css( 'fine-uploader.css', $relative_to ); - + require_js_defer( '#jquery#', $relative_to, true ); // Used to make uploader area resizable: - require_js( '#jqueryUI#', $relative_to ); + require_js_defer( '#jqueryUI#', $relative_to, true ); if( $load_sortable_js ) - { // Load JS files to make the links table sortable: - require_js( 'jquery/jquery.sortable.min.js', $relative_to ); + { // Load JS file uploader with sortable feature for links/attachments: + require_js_defer( 'build/evo_fileuploader_sortable.bmin.js', $relative_to, true ); } + else + { // Load JS file uploader: + require_js_defer( 'build/evo_fileuploader.bmin.js', $relative_to, true ); + } + + // Styles for file uploader: + require_css( 'fine-uploader.css', $relative_to, NULL, NULL, '#', true ); } diff --git a/inc/_core/_url.funcs.php b/inc/_core/_url.funcs.php index 312261b777d..00eeed32bad 100644 --- a/inc/_core/_url.funcs.php +++ b/inc/_core/_url.funcs.php @@ -1004,8 +1004,7 @@ function get_dispctrl_url( $dispctrl, $params = '' ) if( is_admin_page() || empty( $Blog ) ) { // Backoffice part - global $current_User; - if( is_logged_in() && $current_User->check_perm( 'admin', 'restricted' ) && $current_User->check_status( 'can_access_admin' ) ) + if( check_user_perm( 'admin', 'restricted' ) && check_user_status( 'can_access_admin' ) ) { // User must has an access to backoffice global $admin_url; return url_add_param( $admin_url, 'ctrl='.$dispctrl.$params ); @@ -1208,24 +1207,25 @@ function clear_url( $url, $exclude_params ) /** - * Keep only allowed noredir params from current URL in the given URL + * Keep allowed params from current URL in the given URL by config * * @param string Given URL * @param string Separator between URL params - * @param array Additional noredir params for config var $noredir_params. Used for Item's switchable params - * @return string Given URL with allowed noredir params which are found in current URL + * @param array Additional params for config params. Used for Item's switchable params + * @return string Given URL with allowed params which are found in currently opened URL */ -function url_clear_noredir_params( $url, $glue = '&', $custom_noredir_params = array() ) +function url_keep_params( $url, $glue = '&', $custom_keep_params = array() ) { - global $noredir_params; + // By default allow params from this config for all cases: + global $passthru_in_all_redirs__params; - $all_noredir_params = is_array( $custom_noredir_params ) ? $custom_noredir_params : array(); - if( is_array( $noredir_params ) ) - { // Merge config and custom noredir params: - $all_noredir_params = array_merge( $noredir_params, $all_noredir_params ); + $all_keep_params = is_array( $custom_keep_params ) ? $custom_keep_params : array(); + if( is_array( $passthru_in_all_redirs__params ) ) + { // Merge config and custom params: + $all_keep_params = array_merge( $passthru_in_all_redirs__params, $all_keep_params ); } - if( empty( $all_noredir_params ) ) + if( empty( $all_keep_params ) ) { // No allowed params: return $url; } @@ -1237,7 +1237,7 @@ function url_clear_noredir_params( $url, $glue = '&', $custom_noredir_params = a $allowed_params = array(); foreach( $_GET as $param => $value ) { // Check each GET param: - if( in_array( $param, $all_noredir_params ) && // If param is allowed by config $noredir_params + if( in_array( $param, $all_keep_params ) && // If param is allowed by config and custom params ! in_array( $param, $url_params ) ) // If param is NOT defined in the given URL yet { $allowed_params[ $param ] = $value; @@ -1247,4 +1247,73 @@ function url_clear_noredir_params( $url, $glue = '&', $custom_noredir_params = a // Append allowed params from current URL to the given URL: return url_add_param( $url, $allowed_params, $glue ); } + + +/** + * Keep allowed params from current URL in the given Canonical URL + * + * @param string Canonical URL + * @param string Separator between URL params + * @param array Additional params for config params. Used for Item's switchable params + * @return string Canonical URL with allowed params which are found in currently opened URL + */ +function url_keep_canonicals_params( $canonical_url, $glue = '&', $custom_keep_params = array() ) +{ + global $accepted_in_canonicals__params, $accepted_in_canonicals_disp__params, $disp; + + // For canonical URLs we should keep params from additional config: + if( is_array( $accepted_in_canonicals__params ) ) + { // Merge config and custom params: + $custom_keep_params = array_merge( $accepted_in_canonicals__params, $custom_keep_params ); + } + + if( isset( $disp, $accepted_in_canonicals_disp__params[ $disp ] ) && + is_array( $accepted_in_canonicals_disp__params[ $disp ] ) ) + { // Allow also params per current disp: + $custom_keep_params = array_merge( $accepted_in_canonicals_disp__params[ $disp ], $custom_keep_params ); + } + + return url_keep_params( $canonical_url, $glue, $custom_keep_params ); +} + + +/** + * Get URL with same domain as current URL + * + * @param string Original URL to check and use with current domain + * @return string Fixed URL with domain of current URL + */ +function get_same_domain_url( $url ) +{ + global $ReqHost; + + if( ! isset( $ReqHost ) || strpos( $url, $ReqHost ) === 0 ) + { // If domain of original URL is same as current URL domain: + return $url; + } + else + { // Use current domain if domains are different, e.g. when collection URL uses subdomain or different absolute URL: + return preg_replace( '#^https?://[^/]+#i', $ReqHost, $url ); + } +} + + +/** + * Get admin URL + * + * @param string URL params + * @param string Delimiter to use for more params + * @return string Admin URL + */ +function get_admin_url( $url_params = '', $glue = '&' ) +{ + global $admin_url, $current_admin_url; + + if( ! isset( $current_admin_url ) ) + { // Initialize current admin URL once: + $current_admin_url = get_same_domain_url( $admin_url ); + } + + return url_add_param( $current_admin_url, $url_params, $glue ); +} ?> \ No newline at end of file diff --git a/inc/_core/model/_blockcache.class.php b/inc/_core/model/_blockcache.class.php index 1b3d8cfbc8f..00e79711d0a 100644 --- a/inc/_core/model/_blockcache.class.php +++ b/inc/_core/model/_blockcache.class.php @@ -236,8 +236,11 @@ function abort_collect() * * We just concatenate all the individual keys to have a single one * Then we store with the current timestamp + * + * @param boolean TRUE - Flush content on screen, FALSE - Return content as result + * @return string Content if $flush = false */ - function end_collect() + function end_collect( $flush = true ) { global $Debuglog, $servertimenow; @@ -246,10 +249,23 @@ function end_collect() return; } - ob_end_flush(); + if( $flush ) + { // Flush content on screen: + ob_end_flush(); + } + else + { // Return content without flushing it on screen: + $content = ob_get_clean(); + } // We use servertimenow because we may have used data that was loaded at the very start of this page + // NOTE: Call this after ob_end_flush(): $this->cacheproviderstore( $this->serialized_keys, $servertimenow.' '.$this->cached_page_content ); + + if( ! $flush ) + { // Return content: + return $content; + } } diff --git a/inc/_core/model/_module.class.php b/inc/_core/model/_module.class.php index cc35bb4e033..340f6ad2e19 100644 --- a/inc/_core/model/_module.class.php +++ b/inc/_core/model/_module.class.php @@ -420,6 +420,16 @@ function init_backoffice_UI( $params = array() ) function display_backoffice_UI( $params = array() ) { } + + + /** + * Install additional basic plugins + * + * @param array 'old_db_version' - Old DB version to know when plugin can be installed + */ + function install_basic_plugins( $params ) + { + } } ?> \ No newline at end of file diff --git a/inc/_core/model/db/_upgrade.funcs.php b/inc/_core/model/db/_upgrade.funcs.php index f7a30f5a7f1..fdbe98f0beb 100644 --- a/inc/_core/model/db/_upgrade.funcs.php +++ b/inc/_core/model/db/_upgrade.funcs.php @@ -1416,8 +1416,12 @@ function db_delta_table_engines( $tables, $silent ) */ function install_make_db_schema_current( $display = true ) { - global $schema_queries, $DB, $debug; + global $schema_queries, $DB, $debug, $db_config; + // Changing default charset of DB if its not utf8_general_ci: + echo get_install_format_text_and_log( T_('Changing default charset of DB...').'
    '."\n" ); + $DB->query( 'ALTER DATABASE `'.$db_config['name'].'` CHARACTER SET utf8 COLLATE utf8_general_ci' ); + // Go through all tables: foreach( $schema_queries as $table => $query_info ) { @@ -1448,7 +1452,7 @@ function install_make_db_schema_current( $display = true ) { if( count($itemlist) == 1 && $itemlist[0]['type'] == 'create_table' ) { - echo get_install_format_text( $itemlist[0]['note']."
    \n", 'br' ); + echo get_install_format_text_and_log( $itemlist[0]['note']."
    \n", 'br' ); evo_flush(); foreach( $itemlist[0]['queries'] as $query ) { // should be just one, but just in case @@ -1461,22 +1465,22 @@ function install_make_db_schema_current( $display = true ) } else { - echo get_install_format_text( 'Altering table «'.$table.'»...' ); - echo get_install_format_text( '
      ' ); + echo get_install_format_text_and_log( 'Altering table «'.$table.'»...' ); + echo get_install_format_text_and_log( '
        ' ); foreach( $itemlist as $item ) { - echo get_install_format_text( '
      • '.$item['note'], 'li' ); + echo get_install_format_text_and_log( '
      • '.$item['note'], 'li' ); if( $debug ) { pre_dump( $item['queries'] ); } - echo get_install_format_text( '
      • ' ); + echo get_install_format_text_and_log( '' ); foreach( $item['queries'] as $query ) { $DB->query( $query ); } } - echo get_install_format_text( '
      ' ); + echo get_install_format_text_and_log( '
    ' ); } } } diff --git a/inc/_core/ui/_menu.class.php b/inc/_core/ui/_menu.class.php index 1916122ff80..371c8789955 100644 --- a/inc/_core/ui/_menu.class.php +++ b/inc/_core/ui/_menu.class.php @@ -230,8 +230,6 @@ function get_selected( $path ) */ function get_html_menu( $path = NULL, $template = 'main', $level = 0, $force_empty = false ) { - global $current_User; - $r = ''; if( is_null($path) ) diff --git a/inc/_core/ui/forms/_form.class.php b/inc/_core/ui/forms/_form.class.php index 96b8f941e2e..70c54e07d2f 100644 --- a/inc/_core/ui/forms/_form.class.php +++ b/inc/_core/ui/forms/_form.class.php @@ -74,11 +74,6 @@ class Form extends Widget */ var $hiddens = array(); - /** - * Do we need to add javascript for check/uncheck all functionality - */ - var $check_all = false; - /** * Additional Javascript to append to the form, in {@link Form::end_form()}. * @@ -916,6 +911,56 @@ function end_group() return $this->display_or_return( $r ); } + /** + * Open a tab-pane block + * @param array Optional params. + * @return true|string true (if output) or the generated HTML if not outputting + */ + function open_tab_pane( $tab_pane_params = array() ) + { + $tab_pane_params = array_merge( array( + 'class' => 'tab-pane fade', + ), $tab_pane_params ); + + $left_items = ''; + $right_items = ''; + + if( isset( $tab_pane_params['left_items'] ) ) + { + $left_items = $tab_pane_params['left_items']; + unset( $tab_pane_params['left_items'] ); + } + if( isset( $tab_pane_params['right_items'] ) ) + { + $right_items = $tab_pane_params['right_items']; + unset( $tab_pane_params['right_items'] ); + } + + $r = str_replace( '$tab_pane_attribs$', get_field_attribs_as_string( $tab_pane_params ), $this->tab_pane_open ); + $r = str_replace( '$pull_right$', $right_items, $r ); + $r = str_replace( '$pull_left$', $left_items, $r ); + + if( isset($tab_pane_params['id']) ) + { + $r = str_replace( '$id$', $tab_pane_params['id'], $r ); + } + + $r = str_replace( '$class$', $tab_pane_params['class'], $r ); + + return $this->display_or_return( $r ); + } + + /** + * close a tab-pane block. + * + * @return true|string true (if output) or the generated HTML if not outputting + */ + function close_tab_pane() + { + $r = $this->tab_pane_close; + + return $this->display_or_return( $r ); + } /** * Builds a fieldset tag. This is a "fieldset" element by default, but a "th" element @@ -2099,25 +2144,42 @@ function checkbox( $field_name, $field_checked, $field_label = '', $field_note = /** * Return links to check and uncheck all check boxes of the form + * + * @deprecated use Form::checkbox_controls() instead */ function check_all() { - // Need to add event click on links at the form end. - $this->check_all = true; + return $this->checkbox_controls( '$all$', array( 'button_class' => 'btn btn-default' ) ); + } + - $r = ''; + /** + * Control icon/buttons to check/uncheck/reverse all checkboxes by input name + * + * @param string Field name of the checkbox, '$all$' - to control all checkboxes of this Form + * @param array Additional parameters + * @return true|string true (if output) or the generated HTML if not outputting + */ + function checkbox_controls( $field_name = '$all$', $params = array() ) + { + $params = array_merge( array( + 'before_buttons' => '
    ', + 'after_buttons' => '
    ', + 'button_class' => 'btn btn-default btn-xs', + 'icon_class' => 'middle', + ), $params ); - // fp> This is "name=" and I mean it!!! The JS is looking for all elements with this name! - $r .= '
    ' - //.T_('Check all').' ' - .get_icon( 'check_all', 'imgtag', NULL, true ) - .' ' - //.T_('Uncheck all').' ' - .get_icon( 'uncheck_all', 'imgtag', NULL, true ).' '.' '; + $r = $params['before_buttons']; - $r .= ''; + $button_tag_start = ' '; + $r .= $button_tag_start.'="uncheck">'.get_icon( 'uncheck_all', 'imgtag', array( 'class' => $params['icon_class'] ) ).''; + $r .= $button_tag_start.'="reverse">'.T_('Invert').''; + + $r .= $params['after_buttons']; + + return $this->display_or_return( $r ); } @@ -2346,12 +2408,6 @@ function end_form( $buttons = array() ) if( typeof init_dynamicSelect == "function" ) { jQuery( document ).bind( "ready", init_dynamicSelect ); - '; - if( $this->check_all ) - { // Init check_all event on check_all links - $r .= 'jQuery( document ).bind( "ready", init_check_all );'; - } - $r .= ' } '; @@ -2391,11 +2447,11 @@ function end_form( $buttons = array() ) * @param string name * @param string label * @param boolean true to surround checkboxes if they are required - * @param boolean true add a surround_check span, used by check_all mouseover + * @param boolean true add a surround_check span, used by check_all mouseover @deprecated * @param array Params * @return mixed true (if output) or the generated HTML if not outputting */ - function checklist( $options, $field_name, $field_label, $required = false, $add_highlight_spans = false, $field_params = array() ) + function checklist( $options, $field_name, $field_label, $required = false, $dummy = NULL, $field_params = array() ) { $field_params = array_merge( array( 'wide' => false, @@ -2442,16 +2498,6 @@ function checklist( $options, $field_name, $field_label, $required = false, $add // asimo>> add id for label: id = label_for_fieldname_fieldvalue $r .= ''; - if( $add_highlight_spans ) - { // Need it to highlight checkbox for check_all and uncheck_all mouseover - $r .= ''; - $after_field_highlight = ''; - } - else - { - $after_field_highlight = ''; - } - $after_field = ''; if( param_has_error( $field_name ) ) { // There is an error message for this field, we want to mark the checkboxes with a red border: @@ -2483,8 +2529,6 @@ function checklist( $options, $field_name, $field_label, $required = false, $add $r .= $after_field; - $r .= $after_field_highlight; - $r .= ' '.$option[2]; $r .=''; @@ -3707,13 +3751,11 @@ function radio_input( $field_name, $field_value, $field_options, $field_label, $ $field_params['note_format'] = '
    '.$field_params['note_format'].'
    '; } - $field_params['id'] = false; // No ID attribute for the label if( isset( $field_params['required'] ) ) { $field_required = $field_params['required']; } $this->handle_common_params( $field_params, $field_name, $field_label ); - unset($field_params['id']); // unset, so it gets handled correctly as default below $r = $this->begin_field( NULL, NULL, false, 'radio' ); @@ -4967,7 +5009,7 @@ function end_line( $suffix_text = NULL, $field_type = '', $field_params = array( */ function attachments_fieldset( $object, $fold = false, $fieldset_prefix = '' ) { - global $current_User; + global $attachment_tab; // Get object type to initialize link owner $object_type = get_class( $object ); @@ -5024,9 +5066,16 @@ function attachments_fieldset( $object, $fold = false, $fieldset_prefix = '' ) default: debug_die( 'Wrong object type "'.$object_type.'" to display attachments fieldset!' ); } - - // Display attachments fieldset: - display_attachments_fieldset( $this, $LinkOwner, $fold, $fieldset_prefix ); + + // Display attachments: + if( ! $attachment_tab ) + { + display_attachments_fieldset( $this, $LinkOwner, $fold, $fieldset_prefix ); + } + else + { + display_attachments_tab_pane( $this, $LinkOwner, $fold, $fieldset_prefix ); + } // Insert image modal window: echo_image_insert_modal(); @@ -5163,6 +5212,174 @@ function locale_selector( $field_name, $main_locale, $extra_locales, $field_labe return $this->display_or_return( $r ); } + + + /** + * Builds Item selector field + * + * @param string Name/ID of the input field + * @param string Initial value + * @param string Field label + * @param array Extended attributes/parameters + * @return true|string true (if output) or the generated HTML if not outputting + */ + function item_selector( $field_name, $selected_item_ID, $field_label, $field_params = array() ) + { + global $thumbnail_sizes, $file_select_js_initialized; + + $this->handle_common_params( $field_params, $field_name, $field_label ); + + $field_params = array_merge( array( + 'btn_select_title' => NT_('Select'), + 'btn_selected_title' => NT_('Select another'), + 'btn_select_icon' => 'magnifier', + 'btn_select_class' => 'btn btn-sm btn-info', + 'btn_deselect_title' => NT_('Deselect Item'), + 'btn_deselect_icon' => 'remove', + 'window_title_page1' => NT_('Select the Item'), + 'window_title_page2' => NT_('Select the Item').':', + ), $field_params ); + + $r = $this->begin_field(); + + // Hidden field for a selected Item ID: + $r .= ' 'hidden', + 'id' => $field_name, + 'name' => $field_name, + 'value' => $selected_item_ID, + ) ).' />'; + + // Try to get Item by initial ID: + $ItemCache = & get_ItemCache(); + $selected_Item = & $ItemCache->get_by_ID( $selected_item_ID, false, false ); + + // Display info of the selected Item: + $r .= ''; + if( $selected_Item ) + { + $r .= $selected_Item->get_form_selector_info(); + } + $r .= ''; + + // Button to select Item: + $btn_select_title = ( empty( $field_params['btn_select_icon'] ) ? '' : get_icon( $field_params['btn_select_icon'] ).' ' ) + .''.( $selected_Item ? T_( $field_params['btn_selected_title'] ) : T_( $field_params['btn_select_title'] ) ).''; + $r .= ''; + + // Icon to deselect the Item: + $deselector_params = array( + 'id' => 'evo_item_deselector_btn_'.$field_name, + 'title' => T_( $field_params['btn_deselect_title'] ), + 'class' => 'evo_item_deselector_btn pointer', + ); + if( ! $selected_Item ) + { // Hide the deselector icon if no selected Item yet: + $deselector_params['style'] = 'display:none'; + } + $r .= ' '.get_icon( $field_params['btn_deselect_icon'], 'imgtag', $deselector_params ); + + // Initialize different config per each field: + $r .= ''; + + if( empty( $this->item_selector_js_initialized ) ) + { // Initialize JS code for Item selector once: + global $UserSettings, $b2evo_icons_type; + + // Initialize JavaScript to build and open window: + echo_modalwindow_js(); + + // Initialize JavaScript for item selector window: + echo_item_selector_js(); + + // Get last selected collection: + if( ! ( $last_selected_item_coll_ID = $UserSettings->get( 'last_selected_item_coll_ID' ) ) ) + { + global $Blog; + $last_selected_item_coll_ID = empty( $Blog ) ? 0 : $Blog->ID; + } + + $r .= ''; + $this->item_selector_js_initialized = true; + } + + $r .= $this->end_field(); + + return $this->display_or_return( $r ); + } } ?> diff --git a/inc/_core/ui/results/_results.class.php b/inc/_core/ui/results/_results.class.php index ccd39ea43ce..aaa99421b1f 100644 --- a/inc/_core/ui/results/_results.class.php +++ b/inc/_core/ui/results/_results.class.php @@ -1499,9 +1499,11 @@ function display_list_end() $r .= ''; } $r .= ' '; + $r .= ''; $r .= ' '. ' '. ''; + $r .= ''; } else { @@ -1513,9 +1515,11 @@ function display_list_end() { $selector = $this->checkbox_toggle_selectors; } + $r .= ''; $r .= ' '. ' '. ''; + $r .= ''; } if( ! empty( $this->list_mass_actions ) ) diff --git a/inc/_core/ui/results/_resultsel.class.php b/inc/_core/ui/results/_resultsel.class.php index 699be8071b8..eeb9110a149 100644 --- a/inc/_core/ui/results/_resultsel.class.php +++ b/inc/_core/ui/results/_resultsel.class.php @@ -56,12 +56,10 @@ function __construct( $field_ID, $table_selections, $field_sel_ID, $field_sel_na $table_objsel, $field_selected, $field_selection, $current_selection_ID, $sql, $count_sql = NULL, $param_prefix = '', $default_order = '', $limit = 20 ) { - global $current_User; - // Call parent: parent::__construct( $sql, $param_prefix, $default_order, $limit, $count_sql ); - if( ! $current_User->check_perm( 'selections', 'view' ) ) + if( ! check_user_perm( 'selections', 'view' ) ) { // User is NOT allowed to view selections // Don't do any more then base class: return; @@ -89,9 +87,9 @@ function __construct( $field_ID, $table_selections, $field_sel_ID, $field_sel_na */ function display_list_start() { - global $item_ID_array, $current_User; + global $item_ID_array; - if( ! $current_User->check_perm( 'selections', 'view' ) ) + if( ! check_user_perm( 'selections', 'view' ) ) { // User is NOT allowed to view selections // Don't do any more then base class: parent::display_list_start(); @@ -129,9 +127,7 @@ function display_list_start() */ function display_list_end() { - global $current_User; - - if( ! $current_User->check_perm( 'selections', 'view' ) ) + if( ! check_user_perm( 'selections', 'view' ) ) { // User is NOT allowed to view selections // Don't do any more then base class: parent::display_list_end(); @@ -161,16 +157,16 @@ function display_functions() */ function selection_menu() { - global $item_ID_array, $current_User; + global $item_ID_array; - $can_edit = $current_User->check_perm( 'selections', 'edit' ); + $can_edit = check_user_perm( 'selections', 'edit' ); if( $can_edit ) { // links to check all and uncheck all - echo $this->Form->check_all(); + echo $this->Form->checkbox_controls( '$all$', array( 'button_class' => 'btn btn-default' ) ); } - if( $current_User->check_perm( 'selections', 'view' ) ) + if( check_user_perm( 'selections', 'view' ) ) { // construction of the select menu : $selection_name = selection_select_tag( $this->param_prefix, $this->table_selections, $this->field_sel_name, $this->field_sel_ID, $this->current_selection_ID ); @@ -229,7 +225,6 @@ function cols_check( $selection_ID, $sel_table, $sel_table_item, $sel_table_sele */ function selection_checkbox( $item_ID, $param_prefix ) { - global $current_User; // List of checkboxes to pre-check: global $cols_check; // List of already displayed checkboxes (can be used outside to get a list of checkboxes which have been displayed) @@ -244,14 +239,14 @@ function selection_checkbox( $item_ID, $param_prefix ) $r = ''; - if( $current_User->check_perm( 'selections', 'edit' ) ) + if( check_user_perm( 'selections', 'edit' ) ) { // User is allowed to edit - $r .= ''."\n"; // in the onchange attribute, option_db is set to -1 to avoid updating the database - if( $current_User->check_perm( 'selections', 'edit' ) ) + if( check_user_perm( 'selections', 'edit' ) ) { // User is allowed to edit $r .= '\n"; } @@ -376,12 +371,12 @@ function handle_selection_actions( $selection_ID, $prefix, $prefix_sel ) function selection_action( $action, $selection_ID, $selection_name, $prefix, $prefix_sel ) { // the form has been submitted to act on the database and not only to change the display - global $DB, $Messages, $confirm, $item_ID_list, $current_User; + global $DB, $Messages, $confirm, $item_ID_list; $items = param( $prefix.'items', 'array:string', array(), false ); // do NOT memorize // ????????????? param( 'item_ID_list', 'string', '', false ); - $current_User->check_perm( 'selections', 'edit', true ); + check_user_perm( 'selections', 'edit', true ); // Set global vars, selection_.prefix.ID, selection_.prefix_name diff --git a/inc/_ext/_canvascharts.php b/inc/_ext/_canvascharts.php index 2c103e6369b..ea572dfd5d8 100644 --- a/inc/_ext/_canvascharts.php +++ b/inc/_ext/_canvascharts.php @@ -23,12 +23,6 @@ */ function CanvasBarsChart( $chart, $init_js_callback = NULL, $canvas_id = 'canvasbarschart' ) { -?> -
    - - $canvas_id, + 'jqplot_data' => $jqplot_data, + 'jqplot_labels' => $jqplot_legend, + 'jqplot_ticks' => $jqplot_ticks, + 'jqplot_canvas_objects' => $jqplot_canvas_objects, + 'jqplot_link_url' => isset( $chart['link_data']['url'] ) ? $chart['link_data']['url'] : NULL, + 'jqplot_link_dates' => $jqplot_link_dates, + 'jqplot_link_params' => $jqplot_link_params, + 'series_colors' => $series_colors, + 'number_rows' => isset( $chart['legend_numrows'] ) ? (int) $chart['legend_numrows'] : 1, + 'draw_last_line' => isset( $chart['draw_last_line'] ) && $chart['draw_last_line'], + 'init_js_callback' => $init_js_callback, + 'link_data' => isset( $chart['link_data'] ), + ); + + expose_var_to_js( $canvas_id, $js_config, 'evo_init_canvas_charts_config' ); + + echo '
    '; } @@ -348,4 +225,4 @@ function CanvasDonutChart( $chart ) \ No newline at end of file +?> diff --git a/inc/_ext/matomo/SearchEngines.json b/inc/_ext/matomo/SearchEngines.json new file mode 100644 index 00000000000..5263b39997f --- /dev/null +++ b/inc/_ext/matomo/SearchEngines.json @@ -0,0 +1,3914 @@ +{ + "1.cz": [ + { + "urls": [ + "1.cz" + ], + "params": [ + "/s\\/([^\\/]+)/", + "q" + ], + "backlink": "s/{k}", + "charsets": [ + "iso-8859-2" + ] + } + ], + "118 700": [ + { + "urls": [ + "www.118700.se", + "foretag.118700.se", + "webben.118700.se" + ], + "params": [ + "q" + ], + "backlink": "sok.aspx?q={k}" + } + ], + "123people": [ + { + "urls": [ + "www.123people.com", + "123people.{}" + ], + "params": [ + "/s\\/([^\\/]+)/", + "search_term" + ], + "backlink": "s/{k}" + } + ], + "360search": [ + { + "urls": [ + "so.360.cn" + ], + "params": [ + "q" + ], + "backlink": "s?q={k}", + "charsets": [ + "UTF-8", + "gb2312" + ] + }, + { + "urls": [ + "www.so.com", + "m.so.com" + ], + "params": [ + "q" + ], + "backlink": "s?q={k}", + "charsets": [ + "UTF-8", + "gb2312" + ] + } + ], + "Abacho": [ + { + "urls": [ + "www.abacho.de", + "www.abacho.com", + "www.abacho.co.uk", + "www.se.abacho.com", + "www.tr.abacho.com", + "www.abacho.at", + "www.abacho.fr", + "www.abacho.es", + "www.abacho.ch", + "www.abacho.it" + ], + "params": [ + "q" + ], + "backlink": "suche?q={k}" + } + ], + "ABCsøk": [ + { + "urls": [ + "abcsok.no", + "verden.abcsok.no" + ], + "params": [ + "q" + ], + "backlink": "?q={k}" + } + ], + "Acoon": [ + { + "urls": [ + "www.acoon.de" + ], + "params": [ + "begriff" + ], + "backlink": "cgi-bin/search.exe?begriff={k}" + } + ], + "Aguea": [ + { + "urls": [ + "chercherfr.aguea.com" + ], + "params": [ + "q" + ], + "backlink": "s.py?q={k}" + } + ], + "Allaverksamheter": [ + { + "urls": [ + "www.allaverksamheter.se" + ], + "params": [ + "What" + ], + "backlink": "SearchResult.aspx?What={k}" + } + ], + "Alexa": [ + { + "urls": [ + "alexa.com", + "search.toolbars.alexa.com" + ], + "params": [ + "q" + ], + "backlink": "search?q={k}" + } + ], + "Alice Adsl": [ + { + "urls": [ + "rechercher.aliceadsl.fr" + ], + "params": [ + "qs" + ], + "backlink": "google.pl?qs={k}" + } + ], + "All.by": [ + { + "urls": [ + "all.by" + ], + "params": [ + "query" + ], + "backlink": "cgi-bin/search.cgi?mode=by&query={k}" + } + ], + "Allesklar": [ + { + "urls": [ + "www.allesklar.de", + "www.allesklar.at", + "www.allesklar.ch" + ], + "params": [ + "words" + ], + "backlink": "?words={k}" + } + ], + "AllTheWeb": [ + { + "urls": [ + "www.alltheweb.com" + ], + "params": [ + "q" + ], + "backlink": "search?q={k}" + } + ], + "AlohaFind": [ + { + "urls": [ + "alohafind.com" + ], + "params": [ + "q" + ], + "backlink": "search/?q={k}" + } + ], + "AltaVista": [ + { + "urls": [ + "www.altavista.com", + "search.altavista.com", + "listings.altavista.com", + "altavista.de", + "altavista.fr", + "{}.altavista.com", + "be-nl.altavista.com", + "be-fr.altavista.com" + ], + "params": [ + "q" + ], + "backlink": "web/results?q={k}" + } + ], + "AOL": [ + { + "urls": [ + "search.aol.com", + "search.aol.it", + "aolsearch.aol.com", + "www.aolrecherche.aol.fr", + "www.aolrecherches.aol.fr", + "www.aolimages.aol.fr", + "aim.search.aol.com", + "www.recherche.aol.fr", + "recherche.aol.fr", + "find.web.aol.com", + "recherche.aol.ca", + "aolsearch.aol.co.uk", + "search.aol.co.uk", + "aolrecherche.aol.fr", + "sucheaol.aol.de", + "suche.aol.de", + "o2suche.aol.de", + "suche.aolsvc.de", + "aolbusqueda.aol.com.mx", + "alicesuche.aol.de", + "alicesuchet.aol.de", + "suchet2.aol.de", + "search.hp.my.aol.com.au", + "search.hp.my.aol.de", + "search.hp.my.aol.it", + "search-intl.netscape.com" + ], + "params": [ + "query", + "q" + ], + "backlink": "aol/search?q={k}" + }, + { + "urls": [ + "de.aolsearch.com" + ], + "params": [ + "q" + ], + "backlink": "search?q={k}" + } + ], + "Apollo lv": [ + { + "urls": [ + "apollo.lv/portal/search/" + ], + "params": [ + "q" + ], + "backlink": "?cof=FORID%3A11&q={k}&search_where=www" + } + ], + "Apollo7": [ + { + "urls": [ + "apollo7.de" + ], + "params": [ + "query" + ], + "backlink": "a7db/index.php?query={k}&de_sharelook=true&de_bing=true&de_witch=true&de_google=true&de_yahoo=true&de_lycos=true" + } + ], + "Aport": [ + { + "urls": [ + "sm.aport.ru" + ], + "params": [ + "r" + ], + "backlink": "search?r={k}" + } + ], + "Arama": [ + { + "urls": [ + "arama.com" + ], + "params": [ + "q" + ], + "backlink": "search.php3?q={k}" + } + ], + "Arcor": [ + { + "urls": [ + "www.arcor.de" + ], + "params": [ + "Keywords" + ], + "backlink": "content/searchresult.jsp?Keywords={k}" + } + ], + "Arianna": [ + { + "urls": [ + "arianna.libero.it", + "www.arianna.com" + ], + "params": [ + "query" + ], + "backlink": "search/abin/integrata.cgi?query={k}" + } + ], + "Ask": [ + { + "urls": [ + "ask.com", + "web.ask.com", + "int.ask.com", + "mws.ask.com", + "images.ask.com", + "images.{}.ask.com", + "ask.reference.com", + "www.askkids.com", + "iwon.ask.com", + "www.ask.co.uk", + "{}.ask.com", + "www.qbyrd.com", + "{}.qbyrd.com", + "www.search-results.com", + "www1.search-results.com", + "int.search-results.com", + "{}.search-results.com", + "search.ask.com", + "{}.search.ask.com", + "avira-int.ask.com", + "searchqu.com", + "search.tb.ask.com", + "nortonsafe.search.ask.com", + "avira.search.ask.com", + "int.search.tb.ask.com" + ], + "params": [ + "ask", + "q", + "searchfor" + ], + "backlink": "web?q={k}" + } + ], + "Avira SafeSearch": [ + { + "urls": [ + "search.avira.com", + "search.avira.net", + "safesearch.avira.com" + ], + "params": [ + "ask", + "q", + "searchfor" + ], + "backlink": "#/web/result?q={k}", + "hiddenkeyword": [ + "/^$/", + "/" + ] + } + ], + "Atlas": [ + { + "urls": [ + "searchatlas.centrum.cz" + ], + "params": [ + "q" + ], + "backlink": "?q={k}" + } + ], + "auone": [ + { + "urls": [ + "search.auone.jp", + "sp-search.auone.jp" + ], + "params": [ + "q" + ], + "backlink": "?q={k}", + "charsets": [ + "utf-8", + "euc-jp", + "ms932" + ] + } + ], + "auone Images": [ + { + "urls": [ + "sp-image.search.auone.jp" + ], + "params": [ + "q" + ], + "backlink": "?q={k}", + "charsets": [ + "utf-8", + "euc-jp", + "ms932" + ] + } + ], + "Austronaut": [ + { + "urls": [ + "www2.austronaut.at", + "www1.austronaut.at" + ], + "params": [ + "q" + ] + } + ], + "Babylon": [ + { + "urls": [ + "search.babylon.com", + "searchassist.babylon.com" + ], + "params": [ + "q", + "/\\/web\\/(.*)/" + ], + "backlink": "?q={k}" + } + ], + "Baidu": [ + { + "urls": [ + "www.baidu.com", + "www1.baidu.com", + "baidu.com", + "m.baidu.com", + "www.baidu.co.th", + "zhidao.baidu.com", + "tieba.baidu.com", + "news.baidu.com" + ], + "params": [ + "wd", + "word", + "kw" + ], + "backlink": "s?wd={k}", + "charsets": [ + "UTF-8", + "gb2312" + ], + "hiddenkeyword": [ + "/^$/", + "/" + ] + }, + { + "urls": [ + "web.gougou.com" + ], + "params": [ + "search" + ], + "backlink": "search?search={k}" + } + ], + "Biglobe": [ + { + "urls": [ + "cgi.search.biglobe.ne.jp" + ], + "params": [ + "q" + ], + "backlink": "cgi-bin/search-st?q={k}", + "charsets": [ + "utf-8", + "euc-jp", + "ms932" + ] + } + ], + "Biglobe Images": [ + { + "urls": [ + "images.search.biglobe.ne.jp" + ], + "params": [ + "q" + ], + "backlink": "cgi-bin/search-st?q={k}" + } + ], + "Bing": [ + { + "urls": [ + "bing.com", + "{}.bing.com", + "global.bing.com" + ], + "params": [ + "q", + "Q" + ], + "backlink": "search?q={k}", + "hiddenkeyword": [ + "/\\/cr\\?.*/", + "/^$/", + "/" + ] + }, + { + "urls": [ + "msnbc.msn.com", + "dizionario.it.msn.com", + "enciclopedia.it.msn.com", + "cc.bingj.com" + ], + "params": [ + "q", + "Q" + ], + "backlink": "search?q={k}" + } + ], + "Bing Images": [ + { + "urls": [ + "bing.com/images/search", + "{}.bing.com/images/search" + ], + "params": [ + "q", + "Q" + ], + "backlink": "?q={k}" + } + ], + "blekko": [ + { + "urls": [ + "blekko.com" + ], + "params": [ + "q", + "/\\/ws\\/(.*)/" + ], + "backlink": "ws/{k}" + } + ], + "Blogdigger": [ + { + "urls": [ + "www.blogdigger.com" + ], + "params": [ + "q" + ] + } + ], + "Blogpulse": [ + { + "urls": [ + "www.blogpulse.com" + ], + "params": [ + "query" + ], + "backlink": "search?query={k}" + } + ], + "Bluewin": [ + { + "urls": [ + "search.bluewin.ch" + ], + "params": [ + "searchTerm", + "q" + ], + "backlink": "v2/index.php?q={k}" + } + ], + "Canoe.ca": [ + { + "urls": [ + "web.canoe.ca" + ], + "params": [ + "q" + ], + "backlink": "search?q={k}" + } + ], + "Centrum": [ + { + "urls": [ + "search.centrum.cz", + "morfeo.centrum.cz" + ], + "params": [ + "q" + ], + "backlink": "?q={k}" + } + ], + "Charter": [ + { + "urls": [ + "www.charter.net" + ], + "params": [ + "q" + ], + "backlink": "search/index.php?q={k}" + } + ], + "Claro Search": [ + { + "urls": [ + "claro-search.com" + ], + "params": [ + "q" + ], + "backlink": "?q={k}" + } + ], + "Clix": [ + { + "urls": [ + "pesquisa.clix.pt" + ], + "params": [ + "question" + ], + "backlink": "resultado.html?in=Mundial&question={k}" + } + ], + "Cốc Cốc": [ + { + "urls": [ + "coccoc.com" + ], + "params": [ + "query" + ], + "backlink": "search#query={k}" + } + ], + "Comcast": [ + { + "urls": [ + "search.comcast.net" + ], + "params": [ + "q" + ], + "backlink": "?q={k}" + } + ], + "Compuserve.com (Enhanced by Google)": [ + { + "urls": [ + "websearch.cs.com" + ], + "params": [ + "query" + ], + "backlink": "cs/search?query={k}" + } + ], + "Conduit.com": [ + { + "urls": [ + "search.conduit.com", + "images.search.conduit.com" + ], + "params": [ + "q" + ], + "backlink": "Results.aspx?q={k}" + } + ], + "Crawler": [ + { + "urls": [ + "www.crawler.com" + ], + "params": [ + "q" + ], + "backlink": "search/results1.aspx?q={k}" + } + ], + "Cuil": [ + { + "urls": [ + "www.cuil.com" + ], + "params": [ + "q" + ], + "backlink": "search?q={k}" + } + ], + "Daemon search": [ + { + "urls": [ + "daemon-search.com", + "my.daemon-search.com" + ], + "params": [ + "q" + ], + "backlink": "explore/web?q={k}" + } + ], + "DasOertliche": [ + { + "urls": [ + "www.dasoertliche.de" + ], + "params": [ + "kw" + ] + }, + { + "urls": [ + "www2.dasoertliche.de" + ], + "params": [ + "ph", + "kw" + ] + } + ], + "DasTelefonbuch": [ + { + "urls": [ + "www1.dastelefonbuch.de" + ], + "params": [ + "kw" + ] + } + ], + "Daum": [ + { + "urls": [ + "search.daum.net" + ], + "params": [ + "q" + ], + "backlink": "search?q={k}" + } + ], + "Delfi EE": [ + { + "urls": [ + "otsing.delfi.ee" + ], + "params": [ + "q" + ], + "backlink": "find?q={k}" + } + ], + "Delfi lv": [ + { + "urls": [ + "smart.delfi.lv" + ], + "params": [ + "q" + ], + "backlink": "find?q={k}" + } + ], + "Digg": [ + { + "urls": [ + "digg.com" + ], + "params": [ + "s" + ], + "backlink": "search?s={k}" + } + ], + "dir.com": [ + { + "urls": [ + "fr.dir.com" + ], + "params": [ + "req" + ] + } + ], + "DisconnectSearch": [ + { + "urls": [ + "search.disconnect.me" + ], + "params": [], + "hiddenkeyword": [ + "/.*/" + ] + } + ], + "dmoz": [ + { + "urls": [ + "dmoz.org", + "editors.dmoz.org" + ], + "params": [ + "search" + ] + } + ], + "DuckDuckGo": [ + { + "urls": [ + "duckduckgo.com", + "r.duckduckgo.com" + ], + "params": [ + "q" + ], + "hiddenkeyword": [ + "/.*/" + ], + "backlink": "?q={k}" + } + ], + "Earthlink": [ + { + "urls": [ + "search.earthlink.net" + ], + "params": [ + "q" + ], + "backlink": "search?q={k}" + } + ], + "Ecosia": [ + { + "urls": [ + "ecosia.org", + "www.ecosia.org" + ], + "params": [ + "q" + ], + "backlink": "search?q={k}", + "hiddenkeyword": [ + "/^$/", + "/" + ] + } + ], + "El Mundo": [ + { + "urls": [ + "ariadna.elmundo.es" + ], + "params": [ + "q" + ] + } + ], + "Eniro": [ + { + "urls": [ + "www.eniro.se" + ], + "params": [ + "q", + "search_word" + ], + "backlink": "query?q={k}" + } + ], + "Entireweb": [ + { + "urls": [ + "www.entireweb.com" + ], + "params": [ + "q" + ], + "backlink": "web?q={k}" + } + ], + "eo": [ + { + "urls": [ + "eo.st" + ], + "params": [ + "x_query" + ], + "backlink": "cgi-bin/eolost.cgi?x_query={k}" + } + ], + "EpicSearch.in": [ + { + "urls": [ + "epicsearch.in", + "www.epicsearch.in" + ], + "params": [ + "q" + ], + "backlink": "search/?q={k}" + } + ], + "Eurip": [ + { + "urls": [ + "www.eurip.com" + ], + "params": [ + "q" + ], + "backlink": "search/?q={k}" + } + ], + "Euroseek": [ + { + "urls": [ + "www.euroseek.com" + ], + "params": [ + "string" + ], + "backlink": "system/search.cgi?string={k}" + } + ], + "Everyclick": [ + { + "urls": [ + "www.everyclick.com" + ], + "params": [ + "keyword" + ] + } + ], + "Exalead": [ + { + "urls": [ + "www.exalead.fr", + "www.exalead.com" + ], + "params": [ + "q" + ], + "backlink": "search/results?q={k}" + } + ], + "Excite": [ + { + "urls": [ + "search.excite.it", + "search.excite.fr", + "search.excite.de", + "search.excite.co.uk", + "search.excite.es", + "search.excite.nl" + ], + "params": [ + "q" + ], + "backlink": "web/?q={k}" + }, + { + "urls": [ + "msxml.excite.com" + ], + "params": [ + "/\\/[^\\/]+\\/ws\\/results\\/[^\\/]+\\/([^\\/]+)/", + "q" + ] + }, + { + "urls": [ + "www.excite.co.jp" + ], + "params": [ + "search" + ], + "backlink": "search.gw?search={k}", + "charsets": [ + "SHIFT_JIS" + ] + } + ], + "Facebook": [ + { + "urls": [ + "www.facebook.com" + ], + "params": [ + "q" + ], + "backlink": "search/?q={k}" + } + ], + "Fast Browser Search": [ + { + "urls": [ + "www.fastbrowsersearch.com" + ], + "params": [ + "q" + ], + "backlink": "results/results.aspx?q={k}" + } + ], + "Findhurtig": [ + { + "urls": [ + "www.findhurtig.dk" + ], + "params": [ + "q" + ], + "backlink": "web?q={k}" + } + ], + "Fireball": [ + { + "urls": [ + "www.fireball.de" + ], + "params": [ + "q" + ], + "backlink": "ajax.asp?q={k}" + } + ], + "Firstsfind": [ + { + "urls": [ + "www.firstsfind.com" + ], + "params": [ + "qry" + ] + } + ], + "Fixsuche": [ + { + "urls": [ + "www.fixsuche.de" + ], + "params": [ + "q" + ] + } + ], + "Flix.de": [ + { + "urls": [ + "www.flix.de" + ], + "params": [ + "keyword" + ] + } + ], + "Fooooo": [ + { + "urls": [ + "search.fooooo.com" + ], + "params": [ + "q" + ], + "backlink": "web/?q={k}" + } + ], + "Forestle": [ + { + "urls": [ + "forestle.org", + "{}.forestle.org", + "forestle.mobi" + ], + "params": [ + "q" + ], + "backlink": "search.php?q={k}" + } + ], + "Francite": [ + { + "urls": [ + "recherche.francite.com" + ], + "params": [ + "name" + ] + } + ], + "Free": [ + { + "urls": [ + "search.free.fr", + "search1-2.free.fr", + "search1-1.free.fr" + ], + "params": [ + "q", + "qs" + ] + } + ], + "FreeCause": [ + { + "urls": [ + "search.freecause.com" + ], + "params": [ + "p" + ], + "backlink": "?p={k}" + } + ], + "Freenet": [ + { + "urls": [ + "suche.freenet.de" + ], + "params": [ + "query", + "Keywords" + ], + "backlink": "suche/?query={k}" + } + ], + "FriendFeed": [ + { + "urls": [ + "friendfeed.com" + ], + "params": [ + "q" + ], + "backlink": "search?q={k}" + } + ], + "GAIS": [ + { + "urls": [ + "gais.cs.ccu.edu.tw" + ], + "params": [ + "q" + ], + "backlink": "search.php?q={k}" + } + ], + "Genieo": [ + { + "urls": [ + "search.genieo.com" + ], + "params": [ + "q" + ], + "backlink": "&q={k}" + } + ], + "Geona": [ + { + "urls": [ + "geona.net" + ], + "params": [ + "q" + ], + "backlink": "search?q={k}" + } + ], + "Gibiru": [ + { + "urls": [ + "gibiru.com", + "www.gibiru.com" + ], + "params": [ + "q" + ], + "backlink": "results.html?q={k}", + "hiddenkeyword": [ + "/^$/", + "/" + ] + } + ], + "Gigablast": [ + { + "urls": [ + "www.gigablast.com" + ], + "params": [ + "q" + ], + "backlink": "search?q={k}" + } + ], + "Gigablast (Directory)": [ + { + "urls": [ + "dir.gigablast.com" + ], + "params": [ + "q" + ] + } + ], + "Gnadenmeer": [ + { + "urls": [ + "www.gnadenmeer.de" + ], + "params": [ + "keyword" + ] + } + ], + "Gomeo": [ + { + "urls": [ + "www.gomeo.com" + ], + "params": [ + "Keywords", + "/\\/search\\/([^\\/]+)/" + ], + "backlink": "/search/{k}" + } + ], + "goo": [ + { + "urls": [ + "search.goo.ne.jp", + "ocnsearch.goo.ne.jp" + ], + "params": [ + "MT" + ], + "backlink": "web.jsp?MT={k}" + } + ], + "Google": [ + { + "urls": [ + "google.com", + "google.{}", + "encrypted.google.com", + "www2.google.com", + "ipv6.google.com", + "go.google.com", + "wwwgoogle.com", + "wwwgoogle.{}", + "gogole.com", + "gogole.{}", + "gppgle.com", + "gppgle.{}", + "googel.com", + "googel.{}", + "search.avg.com", + "isearch.avg.com" + ], + "params": [ + "q" + ], + "hiddenkeyword": [ + "/^$/", + "/", + "/\\/search(\\?.*)?/", + "/\\/url\\?.*/" + ], + "backlink": "search?q={k}" + }, + { + "urls": [ + "com.google.android.googlequicksearchbox", + "android-app//com.google.android.googlequicksearchbox/https/www.google.com" + ], + "params": [ + "q" + ], + "hiddenkeyword": [ + "/.*/" + ] + }, + { + "urls": [ + "search.chedot.com" + ], + "params": [ + "text" + ] + }, + { + "urls": [ + "www.cnn.com", + "darkoogle.com", + "search.darkoogle.com", + "search.foxtab.com" + ], + "params": [ + "query" + ] + }, + { + "urls": [ + "www.gooofullsearch.com", + "search.hiyo.com", + "search.incredimail.com", + "search1.incredimail.com", + "search2.incredimail.com", + "search3.incredimail.com", + "search4.incredimail.com", + "search.sweetim.com", + "www.fastweb.it" + ], + "params": [ + "Keywords" + ] + }, + { + "urls": [ + "search.juno.com", + "search.zum.com", + "find.tdc.dk", + "it.luna.tv", + "searchresults.verizon.com", + "search.walla.co.il", + "search.alot.com" + ], + "params": [ + "query" + ] + }, + { + "urls": [ + "suche.gmx.net", + "search.gmx.com" + ], + "params": [ + "q" + ], + "backlink": "web?q={k}", + "hiddenkeyword": [ + "/^$/", + "/" + ] + }, + { + "urls": [ + "search.incredibar.com" + ], + "params": [ + "q" + ], + "backlink": "search.php?q={k}" + }, + { + "urls": [ + "www.delta-search.com", + "www1.delta-search.com" + ], + "params": [ + "q" + ] + }, + { + "urls": [ + "search.1und1.de" + ], + "params": [ + "q" + ], + "backlink": "web?q={k}" + }, + { + "urls": [ + "suche.1und1.de", + "search.zonealarm.com" + ], + "params": [ + "q" + ], + "backlink": "web?q={k}" + }, + { + "urls": [ + "start.lenovo.com", + "wow.com", + "{}.wow.com", + "search.leonardo.it", + "www.optuszoo.com.au", + "search.dolphin-browser.jp", + "netlavis.azione.jp", + "search.nan.so" + ], + "params": [ + "q" + ], + "backlink": "search/index.php?q={k}" + }, + { + "urls": [ + "cgi2.nintendo.co.jp" + ], + "params": [ + "gsc.q" + ] + }, + { + "urls": [ + "search.smt.docomo.ne.jp", + "image.search.smt.docomo.ne.jp" + ], + "params": [ + "MT" + ] + }, + { + "urls": [ + "gfsoso.com" + ], + "params": [ + "q" + ] + }, + { + "urls": [ + "searches.safehomepage.com" + ], + "params": [ + "q" + ] + }, + { + "urls": [ + "searches.f-secure.com", + "search.f-secure.com" + ], + "params": [ + "query" + ], + "backlink": "search?query={k}" + }, + { + "urls": [ + "webcache.googleusercontent.com" + ], + "params": [ + "/\\/search\\?q=cache:(?:[A-Za-z0-9]+):[^+]+([^&]+)/" + ], + "backlink": "search?q={k}" + }, + { + "urls": [ + "search.bt.com" + ], + "params": [ + "p" + ], + "backlink": "result?p={k}" + }, + { + "urls": [ + "startab.me" + ], + "params": [ + "q" + ], + "backlink": "search/?q={k}" + } + ], + "Google Blogsearch": [ + { + "urls": [ + "blogsearch.google.com", + "blogsearch.google.{}" + ], + "params": [ + "q" + ], + "backlink": "blogsearch?q={k}" + } + ], + "Google Custom Search": [ + { + "urls": [ + "google.com/cse", + "google.{}/cse", + "cse.google.com", + "cse.google.{}", + "google.com/custom", + "google.{}/custom" + ], + "params": [ + "q", + "query" + ] + } + ], + "Google Images": [ + { + "urls": [ + "images.google.com", + "images.google.{}", + "google.com/imgres", + "google.{}/imgres" + ], + "params": [ + "q" + ], + "hiddenkeyword": [ + "/.*/" + ], + "backlink": "images?q={k}" + } + ], + "Google Maps": [ + { + "urls": [ + "maps.google.com", + "maps.google.{}" + ], + "params": [ + "q" + ], + "backlink": "maps?q={k}" + } + ], + "Google News": [ + { + "urls": [ + "news.google.com", + "news.google.{}" + ], + "params": [ + "q" + ] + } + ], + "Google Scholar": [ + { + "urls": [ + "scholar.google.com", + "scholar.google.{}" + ], + "params": [ + "q" + ], + "backlink": "scholar?q={k}" + } + ], + "Google Shopping": [ + { + "urls": [ + "google.com/products", + "google.{}/products" + ], + "params": [ + "q" + ], + "backlink": "?q={k}&tbm=shop" + } + ], + "Google syndicated search": [ + { + "urls": [ + "googlesyndicatedsearch.com" + ], + "params": [ + "q" + ] + } + ], + "Google Translations": [ + { + "urls": [ + "translate.google.com" + ], + "params": [ + "q" + ] + } + ], + "Google Video": [ + { + "urls": [ + "video.google.com" + ], + "params": [ + "q" + ], + "backlink": "search?q={k}&tbm=vid" + } + ], + "GoYellow.de": [ + { + "urls": [ + "www.goyellow.de" + ], + "params": [ + "MDN" + ] + } + ], + "Gule Sider": [ + { + "urls": [ + "www.gulesider.no" + ], + "params": [ + "q" + ] + } + ], + "Haosou": [ + { + "urls": [ + "www.haosou.com" + ], + "params": [ + "q" + ], + "backlink": "s?q={k}" + } + ], + "HighBeam": [ + { + "urls": [ + "www.highbeam.com" + ], + "params": [ + "q" + ], + "backlink": "Search.aspx?q={k}" + } + ], + "Hit-Parade": [ + { + "urls": [ + "req.hit-parade.com", + "class.hit-parade.com", + "www.hit-parade.com" + ], + "params": [ + "p7" + ], + "backlink": "general/recherche.asp?p7={k}" + } + ], + "Holmes": [ + { + "urls": [ + "holmes.ge" + ], + "params": [ + "q" + ], + "backlink": "search.htm?q={k}" + } + ], + "Hooseek": [ + { + "urls": [ + "www.hooseek.com" + ], + "params": [ + "recherche" + ], + "backlink": "web?recherche={k}" + } + ], + "Hotbot": [ + { + "urls": [ + "www.hotbot.com" + ], + "params": [ + "query" + ] + } + ], + "I-play": [ + { + "urls": [ + "start.iplay.com" + ], + "params": [ + "q" + ], + "backlink": "searchresults.aspx?q={k}" + } + ], + "Icerocket": [ + { + "urls": [ + "blogs.icerocket.com" + ], + "params": [ + "q" + ], + "backlink": "search?q={k}" + } + ], + "ICQ": [ + { + "urls": [ + "www.icq.com", + "search.icq.com" + ], + "params": [ + "q" + ], + "backlink": "search/results.php?q={k}" + } + ], + "Ilse NL": [ + { + "urls": [ + "www.ilse.nl" + ], + "params": [ + "search_for" + ], + "backlink": "?search_for={k}" + } + ], + "iMesh": [ + { + "urls": [ + "search.imesh.com" + ], + "params": [ + "q", + "si" + ], + "backlink": "web?q={k}" + } + ], + "Inbox": [ + { + "urls": [ + "www2.inbox.com" + ], + "params": [ + "q" + ], + "backlink": "search/results1.aspx?q={k}" + } + ], + "InfoSpace": [ + { + "urls": [ + "infospace.com", + "dogpile.com", + "tattoodle.com", + "metacrawler.com", + "webfetch.com", + "webcrawler.com", + "search.kiwee.com", + "searches.vi-view.com", + "search.webssearches.com", + "search.fbdownloader.com", + "searches3.globososo.com" + ], + "params": [ + "q" + ], + "backlink": "/search/web?q={k}" + }, + { + "urls": [ + "wsdsold.infospace.com" + ], + "params": [ + "/\\/[^\\/]+\\/ws\\/results\\/[^\\/]+\\/([^\\/]+)/" + ], + "backlink": "pemonitorhosted/ws/results/Web/{k}/1/417/TopNavigation/Source/" + }, + { + "urls": [ + "search.avast.com" + ], + "params": [ + "q" + ] + }, + { + "urls": [ + "isearch.babylon.com" + ], + "params": [ + "q" + ] + }, + { + "urls": [ + "start.facemoods.com" + ], + "params": [ + "s" + ] + }, + { + "urls": [ + "start.funmoods.com" + ], + "params": [ + "q" + ] + }, + { + "urls": [ + "search.magentic.com" + ], + "params": [ + "q" + ] + }, + { + "urls": [ + "search.searchcompletion.com" + ], + "params": [ + "q" + ] + }, + { + "urls": [ + "www.searchmobileonline.com" + ], + "params": [ + "q" + ] + }, + { + "urls": [ + "isearch.glarysoft.com" + ], + "params": [ + "q" + ] + }, + { + "urls": [ + "search.chatzum.com" + ], + "params": [ + "q" + ] + }, + { + "urls": [ + "home.speedbit.com" + ], + "params": [ + "q" + ] + }, + { + "urls": [ + "search.b1.org" + ], + "params": [ + "q" + ] + }, + { + "urls": [ + "searchya.com" + ], + "params": [ + "q" + ] + }, + { + "urls": [ + "search.handycafe.com" + ], + "params": [ + "q" + ] + }, + { + "urls": [ + "search.v9.com" + ], + "params": [ + "q" + ] + }, + { + "urls": [ + "search.iminent.com" + ], + "params": [ + "q" + ] + }, + { + "urls": [ + "utorrent.inspsearch.com", + "govome.inspsearch.com" + ], + "params": [ + "q" + ] + } + ], + "Interia": [ + { + "urls": [ + "www.google.interia.pl" + ], + "params": [ + "q" + ], + "backlink": "szukaj?q={k}" + } + ], + "Isodelen": [ + { + "urls": [ + "www.isodelen.se" + ], + "params": [ + "Keywords" + ], + "backlink": "sokresultat?Keywords={k}" + } + ], + "IxQuick": [ + { + "urls": [ + "ixquick.com", + "www.eu.ixquick.com", + "ixquick.de", + "www.ixquick.de", + "us.ixquick.com", + "s1.us.ixquick.com", + "s2.us.ixquick.com", + "s3.us.ixquick.com", + "s4.us.ixquick.com", + "s5.us.ixquick.com", + "eu.ixquick.com", + "s8-eu.ixquick.com", + "s1-eu.ixquick.de", + "s2-eu4.ixquick.com", + "s5-eu4.ixquick.com" + ], + "params": [ + "query" + ], + "backlink": "do/asearch?query={k}", + "hiddenkeyword": [ + "/do/asearch" + ] + } + ], + "Jungle Key": [ + { + "urls": [ + "junglekey.com", + "junglekey.fr" + ], + "params": [ + "query" + ], + "backlink": "search.php?query={k}&type=web&lang=en" + } + ], + "Jungle Spider": [ + { + "urls": [ + "www.jungle-spider.de" + ], + "params": [ + "q" + ] + } + ], + "Jyxo": [ + { + "urls": [ + "jyxo.1188.cz" + ], + "params": [ + "q" + ], + "backlink": "s?q={k}" + } + ], + "K9 Safe Search": [ + { + "urls": [ + "k9safesearch.com" + ], + "params": [ + "q" + ], + "backlink": "search.jsp?q={k}" + } + ], + "Kataweb": [ + { + "urls": [ + "www.kataweb.it" + ], + "params": [ + "q" + ] + } + ], + "Kensaq": [ + { + "urls": [ + "www.kensaq.com" + ], + "params": [ + "q" + ], + "backlink": "web?q={k}" + } + ], + "Kvasir": [ + { + "urls": [ + "kvasir.no", + "www.kvasir.no" + ], + "params": [ + "q", + "search_word" + ], + "backlink": "alle?q={k}" + } + ], + "La Toile Du Québec (Google)": [ + { + "urls": [ + "www.toile.com", + "web.toile.com" + ], + "params": [ + "q" + ], + "backlink": "search?q={k}" + } + ], + "Laban": [ + { + "urls": [ + "laban.vn" + ], + "params": [ + "q" + ], + "backlink": "search.html?q={k}" + } + ], + "Latne": [ + { + "urls": [ + "www.latne.lv" + ], + "params": [ + "q" + ], + "backlink": "siets.php?q={k}" + } + ], + "Lilo": [ + { + "urls": [ + "search.lilo.org" + ], + "params": [ + "q" + ], + "backlink": "results.php?q={k}" + } + ], + "Lo.st": [ + { + "urls": [ + "lo.st" + ], + "params": [ + "x_query" + ], + "backlink": "cgi-bin/eolost.cgi?x_query={k}" + } + ], + "LookAny": [ + { + "urls": [ + "www.lookany.com" + ], + "params": [ + "/(?:search|images|videos)\\/([^\\/]+)/" + ] + } + ], + "Lookseek": [ + { + "urls": [ + "search.lookseek.com" + ], + "params": [ + "q" + ], + "backlink": "search2.php?q={k}" + } + ], + "Looksmart": [ + { + "urls": [ + "www.looksmart.com" + ], + "params": [ + "key" + ] + } + ], + "Lycos": [ + { + "urls": [ + "search.lycos.com", + "lycos.{}" + ], + "params": [ + "query" + ], + "backlink": "?query={k}" + } + ], + "maailm.com": [ + { + "urls": [ + "www.maailm.com" + ], + "params": [ + "tekst" + ] + } + ], + "Mailru": [ + { + "urls": [ + "go.mail.ru" + ], + "params": [ + "q" + ], + "backlink": "search?rch=e&q={k}", + "charsets": [ + "UTF-8", + "windows-1251" + ], + "hiddenkeyword": [ + "/redir\\?.*redir=.*/", + "/^$/", + "/" + ] + } + ], + "Mamma": [ + { + "urls": [ + "www.mamma.com", + "mamma75.mamma.com" + ], + "params": [ + "query" + ], + "backlink": "result.php?q={k}" + } + ], + "Meinestadt.de": [ + { + "urls": [ + "www.meinestadt.de" + ], + "params": [ + "words" + ] + } + ], + "Meta.ua": [ + { + "urls": [ + "meta.ua" + ], + "params": [ + "q" + ], + "backlink": "search.asp?q={k}" + } + ], + "MetaCrawler DE": [ + { + "urls": [ + "s1.metacrawler.de", + "s2.metacrawler.de", + "s3.metacrawler.de" + ], + "params": [ + "qry" + ], + "backlink": "?qry={k}" + } + ], + "Metager": [ + { + "urls": [ + "meta.rrzn.uni-hannover.de", + "www.metager.de", + "metager.de" + ], + "params": [ + "eingabe" + ], + "backlink": "meta/cgi-bin/meta.ger1?eingabe={k}" + } + ], + "Metager2": [ + { + "urls": [ + "metager2.de" + ], + "params": [ + "q" + ], + "backlink": "search/index.php?q={k}" + } + ], + "Mister Wong": [ + { + "urls": [ + "www.mister-wong.com", + "www.mister-wong.de" + ], + "params": [ + "keywords" + ], + "backlink": "search/?keywords={k}" + } + ], + "Monstercrawler": [ + { + "urls": [ + "www.monstercrawler.com" + ], + "params": [ + "qry" + ] + } + ], + "mozbot": [ + { + "urls": [ + "www.mozbot.fr", + "www.mozbot.co.uk", + "www.mozbot.com" + ], + "params": [ + "q" + ], + "backlink": "results.php?q={k}" + } + ], + "MySpace": [ + { + "urls": [ + "searchservice.myspace.com" + ], + "params": [ + "qry" + ], + "backlink": "index.cfm?fuseaction=sitesearch.results&type=Web&qry={k}" + } + ], + "MyWebSearch": [ + { + "urls": [ + "www.mysearch.com", + "ms114.mysearch.com", + "ms146.mysearch.com", + "kf.mysearch.myway.com", + "ki.mysearch.myway.com", + "search.myway.com", + "search.mywebsearch.com" + ], + "params": [ + "searchfor", + "searchFor" + ], + "backlink": "search/Ajmain.jhtml?searchfor={k}" + } + ], + "Najdi.si": [ + { + "urls": [ + "www.najdi.si" + ], + "params": [ + "q" + ], + "backlink": "search.jsp?q={k}" + } + ], + "Nate": [ + { + "urls": [ + "search.nate.com" + ], + "params": [ + "q" + ], + "backlink": "search/all.html?q={k}", + "charsets": [ + "EUC-KR" + ] + } + ], + "Naver": [ + { + "urls": [ + "search.naver.com" + ], + "params": [ + "query" + ], + "backlink": "search.naver?query={k}" + } + ], + "Needtofind": [ + { + "urls": [ + "ko.search.need2find.com" + ], + "params": [ + "searchfor" + ], + "backlink": "search/AJmain.jhtml?searchfor={k}" + } + ], + "Neti": [ + { + "urls": [ + "www.neti.ee" + ], + "params": [ + "query" + ], + "backlink": "cgi-bin/otsing?query={k}", + "charsets": [ + "iso-8859-1" + ] + } + ], + "Nifty": [ + { + "urls": [ + "search.nifty.com", + "search.azby.fmworld.net" + ], + "params": [ + "q", + "Text" + ], + "backlink": "websearch/search?q={k}" + } + ], + "Nifty Videos": [ + { + "urls": [ + "videosearch.nifty.com" + ], + "params": [ + "kw" + ], + "backlink": "search?kw={k}" + } + ], + "Nigma": [ + { + "urls": [ + "nigma.ru" + ], + "params": [ + "s" + ], + "backlink": "index.php?s={k}" + } + ], + "Onet.pl": [ + { + "urls": [ + "szukaj.onet.pl" + ], + "params": [ + "qt" + ], + "backlink": "query.html?qt={k}" + } + ], + "Online.no": [ + { + "urls": [ + "online.no" + ], + "params": [ + "q" + ], + "backlink": "google/index.jsp?q={k}" + } + ], + "OnlySearch": [ + { + "urls": [ + "www.only-search.com" + ], + "params": [ + "q" + ], + "backlink": "?q={k}" + } + ], + "Opplysningen 1881": [ + { + "urls": [ + "www.1881.no" + ], + "params": [ + "Query" + ], + "backlink": "Multi/?Query={k}" + } + ], + "Orange": [ + { + "urls": [ + "busca.orange.es" + ], + "params": [ + "q" + ], + "backlink": "search?q={k}" + }, + { + "urls": [ + "lemoteur.ke.voila.fr", + "lemoteur.orange.fr" + ], + "params": [ + "kw" + ], + "backlink": "?kw={k}" + } + ], + "Paperball": [ + { + "urls": [ + "www.paperball.de" + ], + "params": [ + "q" + ], + "backlink": "suche/s/?q={k}" + } + ], + "PeopleCheck": [ + { + "urls": [ + "extern.peoplecheck.de" + ], + "params": [ + "q" + ], + "backlink": "link.php?q={k}" + } + ], + "PeoplePC": [ + { + "urls": [ + "search.peoplepc.com" + ], + "params": [ + "q" + ], + "backlink": "search?q={k}" + } + ], + "Picsearch": [ + { + "urls": [ + "www.picsearch.com" + ], + "params": [ + "q" + ], + "backlink": "index.cgi?q={k}" + } + ], + "Plazoo": [ + { + "urls": [ + "www.plazoo.com" + ], + "params": [ + "q" + ] + } + ], + "PlusNetwork": [ + { + "urls": [ + "plusnetwork.com" + ], + "params": [ + "q" + ], + "backlink": "?q={k}" + } + ], + "Poisk.Ru": [ + { + "urls": [ + "poisk.ru" + ], + "params": [ + "text" + ], + "backlink": "cgi-bin/poisk?text={k}", + "charsets": [ + "windows-1251" + ] + } + ], + "qip.ru": [ + { + "urls": [ + "search.qip.ru" + ], + "params": [ + "query" + ], + "backlink": "search?query={k}" + } + ], + "Qualigo": [ + { + "urls": [ + "www.qualigo.at", + "www.qualigo.ch", + "www.qualigo.de", + "www.qualigo.nl" + ], + "params": [ + "q" + ] + } + ], + "Qwant": [ + { + "urls": [ + "www.qwant.com", + "lite.qwant.com" + ], + "params": [ + "q" + ], + "hiddenkeyword": [ + "/^$/", + "/" + ] + } + ], + "Rakuten": [ + { + "urls": [ + "websearch.rakuten.co.jp" + ], + "params": [ + "qt" + ], + "backlink": "WebIS?qt={k}" + } + ], + "Rambler": [ + { + "urls": [ + "nova.rambler.ru" + ], + "params": [ + "query", + "words" + ], + "backlink": "search?query={k}" + } + ], + "Riksdelen": [ + { + "urls": [ + "www.riksdelen.se" + ], + "params": [ + "What" + ], + "backlink": "SearchResult.aspx?What={k}" + } + ], + "Road Runner": [ + { + "urls": [ + "search.rr.com" + ], + "params": [ + "q" + ], + "backlink": "?q={k}" + } + ], + "rpmfind": [ + { + "urls": [ + "rpmfind.net", + "fr2.rpmfind.net" + ], + "params": [ + "query" + ], + "backlink": "linux/rpm2html/search.php?query={k}" + } + ], + "Sapo": [ + { + "urls": [ + "pesquisa.sapo.pt" + ], + "params": [ + "q" + ], + "backlink": "?q={k}" + } + ], + "Scour.com": [ + { + "urls": [ + "scour.com" + ], + "params": [ + "/search\\/[^\\/]+\\/(.*)/" + ], + "backlink": "search/web/{k}" + } + ], + "Search.ch": [ + { + "urls": [ + "www.search.ch" + ], + "params": [ + "q" + ], + "backlink": "?q={k}" + } + ], + "Search.com": [ + { + "urls": [ + "www.search.com" + ], + "params": [ + "q" + ], + "backlink": "search?q={k}" + } + ], + "Searchalot": [ + { + "urls": [ + "searchalot.com" + ], + "params": [ + "q" + ], + "backlink": "?q={k}" + } + ], + "SearchCanvas": [ + { + "urls": [ + "www.searchcanvas.com" + ], + "params": [ + "q" + ], + "backlink": "web?q={k}" + } + ], + "SearchLock": [ + { + "urls": [ + "searchlock.com", + "results.searchlock.com" + ], + "params": [ + "q" + ], + "hiddenkeyword": [ + "/.*/" + ] + } + ], + "Searchy": [ + { + "urls": [ + "www.searchy.co.uk" + ], + "params": [ + "q" + ], + "backlink": "index.html?q={k}" + } + ], + "SeeSaa": [ + { + "urls": [ + "search.seesaa.jp" + ], + "params": [ + "/\\/([^\\/]+)\\/index\\.html/" + ], + "backlink": "{k}/index.html" + } + ], + "Setooz": [ + { + "urls": [ + "bg.setooz.com", + "da.setooz.com", + "el.setooz.com", + "fa.setooz.com", + "ur.setooz.com", + "{}.setooz.com" + ], + "params": [ + "query" + ], + "backlink": "search?query={k}" + } + ], + "Seznam": [ + { + "urls": [ + "search.seznam.cz" + ], + "params": [ + "q" + ], + "backlink": "?q={k}" + } + ], + "Seznam Videa": [ + { + "urls": [ + "videa.seznam.cz" + ], + "params": [ + "q" + ], + "backlink": "?q={k}" + } + ], + "Sharelook": [ + { + "urls": [ + "www.sharelook.fr" + ], + "params": [ + "keyword" + ] + } + ], + "Skynet": [ + { + "urls": [ + "www.skynet.be" + ], + "params": [ + "q" + ], + "backlink": "services/recherche/google?q={k}" + } + ], + "sm.cn": [ + { + "urls": [ + "m.sm.cn", + "so.m.sm.cn", + "m.sp.sm.cn", + "yz.m.sm.cn", + "quark.sm.cn" + ], + "params": [ + "q" + ], + "backlink": "s?q={k}" + } + ], + "sm.de": [ + { + "urls": [ + "www.sm.de" + ], + "params": [ + "q" + ], + "backlink": "?q={k}" + } + ], + "SmartAddressbar": [ + { + "urls": [ + "search.smartaddressbar.com" + ], + "params": [ + "s" + ], + "backlink": "?s={k}" + } + ], + "SmartShopping": [ + { + "urls": [ + "search.smartshopping.com" + ], + "params": [ + "kwd", + "keywords" + ], + "backlink": "?kwd={k}" + } + ], + "Snap.do": [ + { + "urls": [ + "search.snap.do" + ], + "params": [ + "q" + ], + "backlink": "?q={k}" + } + ], + "So-net": [ + { + "urls": [ + "www.so-net.ne.jp" + ], + "params": [ + "query" + ], + "backlink": "search/web/?query={k}" + } + ], + "So-net Videos": [ + { + "urls": [ + "video.so-net.ne.jp" + ], + "params": [ + "kw" + ], + "backlink": "search/?kw={k}" + } + ], + "Softonic": [ + { + "urls": [ + "search.softonic.com" + ], + "params": [ + "q" + ], + "backlink": "default/default?q={k}" + } + ], + "Sogou": [ + { + "urls": [ + "www.sogou.com", + "sogou.com" + ], + "params": [ + "query" + ], + "backlink": "web?query={k}", + "charsets": [ + "gb2312" + ], + "hiddenkeyword": [ + "/link\\?url=.*/", + "/^$/", + "/" + ] + }, + { + "urls": [ + "m.sogou.com", + "wap.sogou.com", + "english.sogou.com" + ], + "params": [ + "keyword" + ] + } + ], + "Soso": [ + { + "urls": [ + "www.soso.com" + ], + "params": [ + "w" + ], + "backlink": "q?w={k}", + "charsets": [ + "gb2312" + ] + } + ], + "Sputnik": [ + { + "urls": [ + "www.sputnik.ru" + ], + "params": [ + "q" + ], + "backlink": "search?q={k}" + } + ], + "start.fyi": [ + { + "urls": [ + "search.start.fyi" + ], + "params": [ + "q" + ], + "backlink": "?q={k}" + } + ], + "StartPage": [ + { + "urls": [ + "startpage.com", + "classic.startpage.com", + "www.startpage.com", + "eu.startpage.com", + "s6-eu5.ixquick.com", + "s2-eu4.startpage.com", + "s6-eu4.startpage.com", + "s7-eu4.startpage.com", + "s1-eu5.startpage.com", + "s2-eu5.startpage.com", + "s4-eu5.startpage.com", + "s5-eu5.startpage.com", + "s6-eu5.startpage.com", + "s7-eu5.startpage.com", + "s8-eu5.startpage.com", + "s10-eu5.startpage.com", + "s11-eu5.startpage.com", + "s12-eu5.startpage.com", + "s13-eu5.startpage.com", + "s14-eu5.startpage.com" + ], + "params": [ + "query" + ], + "backlink": "do/asearch?query={k}", + "hiddenkeyword": [ + "/do/asearch" + ] + } + ], + "Startpagina (Google)": [ + { + "urls": [ + "startgoogle.startpagina.nl" + ], + "params": [ + "q", + "query" + ], + "backlink": "?q={k}" + } + ], + "Startsiden": [ + { + "urls": [ + "www.startsiden.no" + ], + "params": [ + "q" + ], + "backlink": "sok/index.html?q={k}" + } + ], + "Suche.info": [ + { + "urls": [ + "suche.info" + ], + "params": [ + "Keywords" + ], + "backlink": "suche.php?Keywords={k}" + } + ], + "Suchmaschine.com": [ + { + "urls": [ + "www.suchmaschine.com" + ], + "params": [ + "suchstr" + ], + "backlink": "cgi-bin/wo.cgi?suchstr={k}" + } + ], + "Suchnase": [ + { + "urls": [ + "www.suchnase.de" + ], + "params": [ + "q" + ] + } + ], + "Surf Canyon": [ + { + "urls": [ + "surfcanyon.com" + ], + "params": [ + "q" + ] + } + ], + "T-Online": [ + { + "urls": [ + "suche.t-online.de", + "brisbane.t-online.de" + ], + "params": [ + "q" + ], + "backlink": "fast-cgi/tsc?mandant=toi&context=internet-tab&q={k}", + "hiddenkeyword": [ + "/^$/", + "/" + ] + }, + { + "urls": [ + "navigationshilfe.t-online.de" + ], + "params": [ + "q" + ], + "backlink": "dtag/dns/results?mode=search_top&q={k}" + } + ], + "talimba": [ + { + "urls": [ + "www.talimba.com" + ], + "params": [ + "search" + ], + "backlink": "index.php?page=search/web&search={k}" + } + ], + "TalkTalk": [ + { + "urls": [ + "www.talktalk.co.uk" + ], + "params": [ + "query" + ], + "backlink": "search/results.html?query={k}" + } + ], + "Tarmot": [ + { + "urls": [ + "tarmot.com" + ], + "params": [ + "q" + ], + "backlink": "ara/?q={k}" + } + ], + "Technorati": [ + { + "urls": [ + "technorati.com" + ], + "params": [ + "q" + ], + "backlink": "search?return=sites&authority=all&q={k}" + } + ], + "Teoma": [ + { + "urls": [ + "www.teoma.com" + ], + "params": [ + "q" + ], + "backlink": "web?q={k}" + } + ], + "Terra": [ + { + "urls": [ + "buscador.terra.es", + "buscador.terra.cl", + "buscador.terra.com.br" + ], + "params": [ + "query" + ], + "backlink": "Default.aspx?source=Search&query={k}" + } + ], + "Tiscali": [ + { + "urls": [ + "search.tiscali.it", + "search-dyn.tiscali.it" + ], + "params": [ + "q", + "key" + ], + "backlink": "?q={k}" + }, + { + "urls": [ + "hledani.tiscali.cz" + ], + "params": [ + "query" + ] + } + ], + "Tixuma": [ + { + "urls": [ + "www.tixuma.de" + ], + "params": [ + "sc" + ], + "backlink": "index.php?mp=search&stp=&sc={k}&tg=0" + } + ], + "Toolbarhome": [ + { + "urls": [ + "www.toolbarhome.com", + "vshare.toolbarhome.com" + ], + "params": [ + "q" + ], + "backlink": "search.aspx?q={k}" + } + ], + "Toppreise.ch": [ + { + "urls": [ + "www.toppreise.ch", + "toppreise.ch", + "fr.toppreise.ch", + "de.toppreise.ch", + "en.toppreise.ch" + ], + "params": [ + "search" + ], + "backlink": "index.php?search={k}", + "charsets": [ + "ISO-8859-1" + ] + } + ], + "Trouvez.com": [ + { + "urls": [ + "www.trouvez.com" + ], + "params": [ + "query" + ] + } + ], + "TrovaRapido": [ + { + "urls": [ + "www.trovarapido.com" + ], + "params": [ + "q" + ], + "backlink": "result.php?q={k}" + } + ], + "Trusted Search": [ + { + "urls": [ + "www.trusted-search.com" + ], + "params": [ + "w" + ], + "backlink": "search?w={k}" + } + ], + "Twingly": [ + { + "urls": [ + "www.twingly.com" + ], + "params": [ + "q" + ], + "backlink": "search?q={k}" + } + ], + "uol.com.br": [ + { + "urls": [ + "busca.uol.com.br" + ], + "params": [ + "q" + ], + "backlink": "/web/?q={k}" + } + ], + "URL.ORGanzier": [ + { + "urls": [ + "www.url.org" + ], + "params": [ + "q" + ], + "backlink": "?l=de&q={k}" + } + ], + "Vinden": [ + { + "urls": [ + "www.vinden.nl" + ], + "params": [ + "q" + ], + "backlink": "?q={k}" + } + ], + "Vindex": [ + { + "urls": [ + "www.vindex.nl", + "search.vindex.nl" + ], + "params": [ + "search_for" + ], + "backlink": "/web?search_for={k}" + } + ], + "Virgilio": [ + { + "urls": [ + "ricerca.virgilio.it", + "ricercaimmagini.virgilio.it", + "ricercavideo.virgilio.it", + "ricercanews.virgilio.it" + ], + "params": [ + "qs" + ], + "backlink": "ricerca?qs={k}" + }, + { + "urls": [ + "mobile.virgilio.it" + ], + "params": [ + "qrs" + ] + } + ], + "Voila": [ + { + "urls": [ + "search.ke.voila.fr", + "www.lemoteur.fr" + ], + "params": [ + "rdata" + ], + "backlink": "S/voila?rdata={k}" + } + ], + "Volny": [ + { + "urls": [ + "web.volny.cz" + ], + "params": [ + "search" + ], + "backlink": "fulltext/?search={k}", + "charsets": [ + "windows-1250" + ] + } + ], + "Walhello": [ + { + "urls": [ + "www.walhello.info", + "www.walhello.com", + "www.walhello.de", + "www.walhello.nl" + ], + "params": [ + "key" + ], + "backlink": "search?key={k}" + } + ], + "Web.de": [ + { + "urls": [ + "suche.web.de", + "m.suche.web.de" + ], + "params": [ + "su", + "q" + ], + "backlink": "search/web/?su={k}", + "hiddenkeyword": [ + "/^$/", + "/" + ] + } + ], + "Web.nl": [ + { + "urls": [ + "www.web.nl" + ], + "params": [ + "zoekwoord" + ] + } + ], + "weborama": [ + { + "urls": [ + "www.weborama.fr" + ], + "params": [ + "QUERY" + ] + } + ], + "WebSearch": [ + { + "urls": [ + "www.websearch.com" + ], + "params": [ + "qkw", + "q" + ], + "backlink": "search/results2.aspx?q={k}" + } + ], + "Wedoo": [ + { + "urls": [ + "fr.wedoo.com", + "en.wedoo.com", + "es.wedoo.com" + ], + "params": [ + "keyword" + ] + } + ], + "Winamp": [ + { + "urls": [ + "search.winamp.com" + ], + "params": [ + "q" + ], + "backlink": "search/search?q={k}" + } + ], + "Wirtualna Polska": [ + { + "urls": [ + "szukaj.wp.pl" + ], + "params": [ + "szukaj" + ], + "backlink": "http://szukaj.wp.pl/szukaj.html?szukaj={k}" + } + ], + "Witch": [ + { + "urls": [ + "www.witch.de" + ], + "params": [ + "search" + ], + "backlink": "search-result.php?cn=0&search={k}" + } + ], + "Woopie": [ + { + "urls": [ + "www.woopie.jp" + ], + "params": [ + "kw" + ], + "backlink": "search?kw={k}" + } + ], + "www värav": [ + { + "urls": [ + "search.www.ee" + ], + "params": [ + "query" + ] + } + ], + "X-Recherche": [ + { + "urls": [ + "www.x-recherche.com" + ], + "params": [ + "MOTS" + ], + "backlink": "cgi-bin/websearch?MOTS={k}" + } + ], + "Yahoo!": [ + { + "urls": [ + "search.yahoo.com", + "malaysia.search.yahoo.com", + "{}.search.yahoo.com", + "cade.yahoo.com", + "espanol.search.yahoo.com", + "qc.search.yahoo.com", + "one.cn.yahoo.com" + ], + "params": [ + "p", + "q" + ], + "backlink": "search?p={k}", + "hiddenkeyword": [ + "/\\/r\\/.*/", + "/^$/", + "/" + ] + }, + { + "urls": [ + "r.search.yahoo.com" + ], + "params": [], + "hiddenkeyword": [ + "/.*/" + ] + }, + { + "urls": [ + "www.cercato.it" + ], + "params": [ + "q" + ] + }, + { + "urls": [ + "search.offerbox.com" + ], + "params": [ + "q" + ] + }, + { + "urls": [ + "www.benefind.de" + ], + "params": [ + "q" + ] + }, + { + "urls": [ + "ys.mirostart.com" + ], + "params": [ + "q" + ] + } + ], + "Yahoo! Directory": [ + { + "urls": [ + "search.yahoo.com/search/dir" + ], + "params": [ + "p" + ], + "backlink": "?p={k}" + } + ], + "Yahoo! Images": [ + { + "urls": [ + "images.search.yahoo.com", + "{}.images.yahoo.com", + "cade.images.yahoo.com", + "espanol.images.yahoo.com", + "qc.images.yahoo.com" + ], + "params": [ + "p", + "va" + ], + "backlink": "search/images?p={k}" + } + ], + "Yahoo! Japan": [ + { + "urls": [ + "search.yahoo.co.jp" + ], + "params": [ + "p", + "vp" + ], + "backlink": "search?p={k}", + "charsets": [ + "utf-8", + "euc-jp", + "ms932" + ], + "hiddenkeyword": [ + "/\\/r\\/.*/", + "/^$/", + "/" + ] + }, + { + "urls": [ + "jp.hao123.com" + ], + "params": [ + "query" + ] + }, + { + "urls": [ + "home.kingsoft.jp" + ], + "params": [ + "keyword" + ] + }, + { + "urls": [ + "jwsearch.jword.jp" + ], + "params": [ + "q" + ] + } + ], + "Yahoo! Japan Images": [ + { + "urls": [ + "image.search.yahoo.co.jp" + ], + "params": [ + "p" + ], + "backlink": "search?p={k}", + "charsets": [ + "utf-8", + "euc-jp", + "ms932" + ] + } + ], + "Yahoo! Japan Videos": [ + { + "urls": [ + "video.search.yahoo.co.jp" + ], + "params": [ + "p" + ], + "backlink": "search?p={k}", + "charsets": [ + "utf-8", + "euc-jp", + "ms932" + ] + } + ], + "Yam": [ + { + "urls": [ + "search.yam.com" + ], + "params": [ + "k" + ], + "backlink": "Search/Web/?SearchType=web&k={k}" + } + ], + "Yandex": [ + { + "urls": [ + "yandex.ru", + "yandex.com", + "yandex.{}", + "www.yandex.{}", + "clck.yandex.{}", + "m.yandex.{}" + ], + "params": [ + "text" + ], + "backlink": "yandsearch?text={k}", + "hiddenkeyword": [ + "/^$/", + "/" + ] + }, + { + "urls": [ + "yabs.yandex.{}" + ], + "params": [ + "q" + ] + } + ], + "Yandex Images": [ + { + "urls": [ + "images.yandex.ru", + "images.yandex.com", + "images.yandex.{}" + ], + "params": [ + "text" + ], + "backlink": "yandsearch?text={k}" + } + ], + "Yasni": [ + { + "urls": [ + "www.yasni.de", + "www.yasni.com", + "www.yasni.co.uk", + "www.yasni.ch", + "www.yasni.at" + ], + "params": [ + "query" + ] + } + ], + "Yatedo": [ + { + "urls": [ + "www.yatedo.com", + "www.yatedo.fr" + ], + "params": [ + "q" + ], + "backlink": "search/profil?q={k}" + } + ], + "Yellowmap": [ + { + "urls": [ + "yellowmap.de" + ], + "params": [ + " " + ] + } + ], + "Yippy": [ + { + "urls": [ + "search.yippy.com" + ], + "params": [ + "query" + ], + "backlink": "search?query={k}" + } + ], + "YouGoo": [ + { + "urls": [ + "www.yougoo.fr" + ], + "params": [ + "q" + ], + "backlink": "?cx=search&q={k}" + } + ], + "Zapmeta": [ + { + "urls": [ + "www.zapmeta.com", + "zapmeta.{}", + "uk.zapmeta.com", + "ar.zapmeta.com", + "au.zapmeta.com", + "ca.zapmeta.com", + "fi.zapmeta.com", + "no.zapmeta.com", + "tr.zapmeta.com" + ], + "params": [ + "q", + "query" + ], + "backlink": "?q={k}" + } + ], + "Zhongsou": [ + { + "urls": [ + "p.zhongsou.com" + ], + "params": [ + "w" + ], + "backlink": "p?w={k}" + } + ], + "Zoek": [ + { + "urls": [ + "www3.zoek.nl" + ], + "params": [ + "q" + ] + } + ], + "Zoeken": [ + { + "urls": [ + "www.zoeken.nl" + ], + "params": [ + "q" + ], + "backlink": "?q={k}" + } + ], + "Zoohoo": [ + { + "urls": [ + "zoohoo.cz" + ], + "params": [ + "q" + ], + "backlink": "?q={k}", + "charsets": [ + "windows-1250" + ] + } + ], + "Zoznam": [ + { + "urls": [ + "www.zoznam.sk" + ], + "params": [ + "s" + ], + "backlink": "hladaj.fcgi?s={k}&co=svet" + } + ], + "Zxuso": [ + { + "urls": [ + "www.zxuso.com" + ], + "params": [ + "wd" + ], + "backlink": "ri/?wd={k}" + } + ], + "묻지마 검색": [ + { + "urls": [ + "kwzf.net" + ], + "params": [ + "search" + ], + "backlink": "#search={k}" + } + ] + } \ No newline at end of file diff --git a/inc/_ext/random/byte_safe_strings.php b/inc/_ext/random/byte_safe_strings.php new file mode 100644 index 00000000000..ef24488f9e7 --- /dev/null +++ b/inc/_ext/random/byte_safe_strings.php @@ -0,0 +1,195 @@ + RandomCompat_strlen($binary_string)) { + return ''; + } + + return (string) mb_substr( + (string) $binary_string, + (int) $start, + (int) $length, + '8bit' + ); + } + + } else { + + /** + * substr() implementation that isn't brittle to mbstring.func_overload + * + * This version just uses the default substr() + * + * @param string $binary_string + * @param int $start + * @param int|null $length (optional) + * + * @throws TypeError + * + * @return string + */ + function RandomCompat_substr($binary_string, $start, $length = null) + { + if (!is_string($binary_string)) { + throw new TypeError( + 'RandomCompat_substr(): First argument should be a string' + ); + } + + if (!is_int($start)) { + throw new TypeError( + 'RandomCompat_substr(): Second argument should be an integer' + ); + } + + if ($length !== null) { + if (!is_int($length)) { + throw new TypeError( + 'RandomCompat_substr(): Third argument should be an integer, or omitted' + ); + } + + return (string) substr( + (string )$binary_string, + (int) $start, + (int) $length + ); + } + + return (string) substr( + (string) $binary_string, + (int) $start + ); + } + } +} diff --git a/inc/_ext/random/cast_to_int.php b/inc/_ext/random/cast_to_int.php new file mode 100644 index 00000000000..1b1bbfe8dee --- /dev/null +++ b/inc/_ext/random/cast_to_int.php @@ -0,0 +1,77 @@ + operators might accidentally let a float + * through. + * + * @param int|float $number The number we want to convert to an int + * @param bool $fail_open Set to true to not throw an exception + * + * @return float|int + * @psalm-suppress InvalidReturnType + * + * @throws TypeError + */ + function RandomCompat_intval($number, $fail_open = false) + { + if (is_int($number) || is_float($number)) { + $number += 0; + } elseif (is_numeric($number)) { + /** @psalm-suppress InvalidOperand */ + $number += 0; + } + /** @var int|float $number */ + + if ( + is_float($number) + && + $number > ~PHP_INT_MAX + && + $number < PHP_INT_MAX + ) { + $number = (int) $number; + } + + if (is_int($number)) { + return (int) $number; + } elseif (!$fail_open) { + throw new TypeError( + 'Expected an integer.' + ); + } + return $number; + } +} diff --git a/inc/_ext/random/error_polyfill.php b/inc/_ext/random/error_polyfill.php new file mode 100644 index 00000000000..c02c5c8b4cd --- /dev/null +++ b/inc/_ext/random/error_polyfill.php @@ -0,0 +1,49 @@ += 70000) { + return; +} + +if (!defined('RANDOM_COMPAT_READ_BUFFER')) { + define('RANDOM_COMPAT_READ_BUFFER', 8); +} + +$RandomCompatDIR = dirname(__FILE__); + +require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'byte_safe_strings.php'; +require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'cast_to_int.php'; +require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'error_polyfill.php'; + +if (!is_callable('random_bytes')) { + /** + * PHP 5.2.0 - 5.6.x way to implement random_bytes() + * + * We use conditional statements here to define the function in accordance + * to the operating environment. It's a micro-optimization. + * + * In order of preference: + * 1. Use libsodium if available. + * 2. fread() /dev/urandom if available (never on Windows) + * 3. mcrypt_create_iv($bytes, MCRYPT_DEV_URANDOM) + * 4. COM('CAPICOM.Utilities.1')->GetRandom() + * + * See RATIONALE.md for our reasoning behind this particular order + */ + if (extension_loaded('libsodium')) { + // See random_bytes_libsodium.php + if (PHP_VERSION_ID >= 50300 && is_callable('\\Sodium\\randombytes_buf')) { + require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'random_bytes_libsodium.php'; + } elseif (method_exists('Sodium', 'randombytes_buf')) { + require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'random_bytes_libsodium_legacy.php'; + } + } + + /** + * Reading directly from /dev/urandom: + */ + if (DIRECTORY_SEPARATOR === '/') { + // DIRECTORY_SEPARATOR === '/' on Unix-like OSes -- this is a fast + // way to exclude Windows. + $RandomCompatUrandom = true; + $RandomCompat_basedir = ini_get('open_basedir'); + + if (!empty($RandomCompat_basedir)) { + $RandomCompat_open_basedir = explode( + PATH_SEPARATOR, + strtolower($RandomCompat_basedir) + ); + $RandomCompatUrandom = (array() !== array_intersect( + array('/dev', '/dev/', '/dev/urandom'), + $RandomCompat_open_basedir + )); + $RandomCompat_open_basedir = null; + } + + if ( + !is_callable('random_bytes') + && + $RandomCompatUrandom + && + @is_readable('/dev/urandom') + ) { + // Error suppression on is_readable() in case of an open_basedir + // or safe_mode failure. All we care about is whether or not we + // can read it at this point. If the PHP environment is going to + // panic over trying to see if the file can be read in the first + // place, that is not helpful to us here. + + // See random_bytes_dev_urandom.php + require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'random_bytes_dev_urandom.php'; + } + // Unset variables after use + $RandomCompat_basedir = null; + } else { + $RandomCompatUrandom = false; + } + + /** + * mcrypt_create_iv() + * + * We only want to use mcypt_create_iv() if: + * + * - random_bytes() hasn't already been defined + * - the mcrypt extensions is loaded + * - One of these two conditions is true: + * - We're on Windows (DIRECTORY_SEPARATOR !== '/') + * - We're not on Windows and /dev/urandom is readabale + * (i.e. we're not in a chroot jail) + * - Special case: + * - If we're not on Windows, but the PHP version is between + * 5.6.10 and 5.6.12, we don't want to use mcrypt. It will + * hang indefinitely. This is bad. + * - If we're on Windows, we want to use PHP >= 5.3.7 or else + * we get insufficient entropy errors. + */ + if ( + !is_callable('random_bytes') + && + // Windows on PHP < 5.3.7 is broken, but non-Windows is not known to be. + (DIRECTORY_SEPARATOR === '/' || PHP_VERSION_ID >= 50307) + && + // Prevent this code from hanging indefinitely on non-Windows; + // see https://bugs.php.net/bug.php?id=69833 + ( + DIRECTORY_SEPARATOR !== '/' || + (PHP_VERSION_ID <= 50609 || PHP_VERSION_ID >= 50613) + ) + && + extension_loaded('mcrypt') + ) { + // See random_bytes_mcrypt.php + require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'random_bytes_mcrypt.php'; + } + $RandomCompatUrandom = null; + + /** + * This is a Windows-specific fallback, for when the mcrypt extension + * isn't loaded. + */ + if ( + !is_callable('random_bytes') + && + extension_loaded('com_dotnet') + && + class_exists('COM') + ) { + $RandomCompat_disabled_classes = preg_split( + '#\s*,\s*#', + strtolower(ini_get('disable_classes')) + ); + + if (!in_array('com', $RandomCompat_disabled_classes)) { + try { + $RandomCompatCOMtest = new COM('CAPICOM.Utilities.1'); + /** @psalm-suppress TypeDoesNotContainType */ + if (is_callable(array($RandomCompatCOMtest, 'GetRandom'))) { + // See random_bytes_com_dotnet.php + require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'random_bytes_com_dotnet.php'; + } + } catch (com_exception $e) { + // Don't try to use it. + } + } + $RandomCompat_disabled_classes = null; + $RandomCompatCOMtest = null; + } + + /** + * throw new Exception + */ + if (!is_callable('random_bytes')) { + /** + * We don't have any more options, so let's throw an exception right now + * and hope the developer won't let it fail silently. + * + * @param mixed $length + * @psalm-suppress InvalidReturnType + * @throws Exception + * @return string + */ + function random_bytes($length) + { + unset($length); // Suppress "variable not used" warnings. + throw new Exception( + 'There is no suitable CSPRNG installed on your system' + ); + return ''; + } + } +} + +if (!is_callable('random_int')) { + require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'random_int.php'; +} + +$RandomCompatDIR = null; diff --git a/inc/_ext/random/random_bytes_com_dotnet.php b/inc/_ext/random/random_bytes_com_dotnet.php new file mode 100644 index 00000000000..537d02b27a3 --- /dev/null +++ b/inc/_ext/random/random_bytes_com_dotnet.php @@ -0,0 +1,91 @@ +GetRandom($bytes, 0)); + if (RandomCompat_strlen($buf) >= $bytes) { + /** + * Return our random entropy buffer here: + */ + return (string) RandomCompat_substr($buf, 0, $bytes); + } + ++$execCount; + } while ($execCount < $bytes); + + /** + * If we reach here, PHP has failed us. + */ + throw new Exception( + 'Could not gather sufficient random data' + ); + } +} diff --git a/inc/_ext/random/random_bytes_dev_urandom.php b/inc/_ext/random/random_bytes_dev_urandom.php new file mode 100644 index 00000000000..c4e31ccbbbe --- /dev/null +++ b/inc/_ext/random/random_bytes_dev_urandom.php @@ -0,0 +1,190 @@ + $st */ + $st = fstat($fp); + if (($st['mode'] & 0170000) !== 020000) { + fclose($fp); + $fp = false; + } + } + } + + if (is_resource($fp)) { + /** + * stream_set_read_buffer() does not exist in HHVM + * + * If we don't set the stream's read buffer to 0, PHP will + * internally buffer 8192 bytes, which can waste entropy + * + * stream_set_read_buffer returns 0 on success + */ + if (is_callable('stream_set_read_buffer')) { + stream_set_read_buffer($fp, RANDOM_COMPAT_READ_BUFFER); + } + if (is_callable('stream_set_chunk_size')) { + stream_set_chunk_size($fp, RANDOM_COMPAT_READ_BUFFER); + } + } + } + + try { + /** @var int $bytes */ + $bytes = RandomCompat_intval($bytes); + } catch (TypeError $ex) { + throw new TypeError( + 'random_bytes(): $bytes must be an integer' + ); + } + + if ($bytes < 1) { + throw new Error( + 'Length must be greater than 0' + ); + } + + /** + * This if() block only runs if we managed to open a file handle + * + * It does not belong in an else {} block, because the above + * if (empty($fp)) line is logic that should only be run once per + * page load. + */ + if (is_resource($fp)) { + /** + * @var int + */ + $remaining = $bytes; + + /** + * @var string|bool + */ + $buf = ''; + + /** + * We use fread() in a loop to protect against partial reads + */ + do { + /** + * @var string|bool + */ + $read = fread($fp, $remaining); + if (!is_string($read)) { + /** + * We cannot safely read from the file. Exit the + * do-while loop and trigger the exception condition + * + * @var string|bool + */ + $buf = false; + break; + } + /** + * Decrease the number of bytes returned from remaining + */ + $remaining -= RandomCompat_strlen($read); + /** + * @var string $buf + */ + $buf .= $read; + } while ($remaining > 0); + + /** + * Is our result valid? + * @var string|bool $buf + */ + if (is_string($buf)) { + if (RandomCompat_strlen($buf) === $bytes) { + /** + * Return our random entropy buffer here: + */ + return $buf; + } + } + } + + /** + * If we reach here, PHP has failed us. + */ + throw new Exception( + 'Error reading from source device' + ); + } +} diff --git a/inc/_ext/random/random_bytes_libsodium.php b/inc/_ext/random/random_bytes_libsodium.php new file mode 100644 index 00000000000..2e562901829 --- /dev/null +++ b/inc/_ext/random/random_bytes_libsodium.php @@ -0,0 +1,91 @@ + 2147483647) { + $buf = ''; + for ($i = 0; $i < $bytes; $i += 1073741824) { + $n = ($bytes - $i) > 1073741824 + ? 1073741824 + : $bytes - $i; + $buf .= \Sodium\randombytes_buf($n); + } + } else { + /** @var string|bool $buf */ + $buf = \Sodium\randombytes_buf($bytes); + } + + if (is_string($buf)) { + if (RandomCompat_strlen($buf) === $bytes) { + return $buf; + } + } + + /** + * If we reach here, PHP has failed us. + */ + throw new Exception( + 'Could not gather sufficient random data' + ); + } +} diff --git a/inc/_ext/random/random_bytes_libsodium_legacy.php b/inc/_ext/random/random_bytes_libsodium_legacy.php new file mode 100644 index 00000000000..f78b2199a2b --- /dev/null +++ b/inc/_ext/random/random_bytes_libsodium_legacy.php @@ -0,0 +1,93 @@ + 2147483647) { + for ($i = 0; $i < $bytes; $i += 1073741824) { + $n = ($bytes - $i) > 1073741824 + ? 1073741824 + : $bytes - $i; + $buf .= Sodium::randombytes_buf((int) $n); + } + } else { + $buf .= Sodium::randombytes_buf((int) $bytes); + } + + if (is_string($buf)) { + if (RandomCompat_strlen($buf) === $bytes) { + return $buf; + } + } + + /** + * If we reach here, PHP has failed us. + */ + throw new Exception( + 'Could not gather sufficient random data' + ); + } +} diff --git a/inc/_ext/random/random_bytes_mcrypt.php b/inc/_ext/random/random_bytes_mcrypt.php new file mode 100644 index 00000000000..0b13fa73c5d --- /dev/null +++ b/inc/_ext/random/random_bytes_mcrypt.php @@ -0,0 +1,79 @@ + operators might accidentally let a float + * through. + */ + + try { + /** @var int $min */ + $min = RandomCompat_intval($min); + } catch (TypeError $ex) { + throw new TypeError( + 'random_int(): $min must be an integer' + ); + } + + try { + /** @var int $max */ + $max = RandomCompat_intval($max); + } catch (TypeError $ex) { + throw new TypeError( + 'random_int(): $max must be an integer' + ); + } + + /** + * Now that we've verified our weak typing system has given us an integer, + * let's validate the logic then we can move forward with generating random + * integers along a given range. + */ + if ($min > $max) { + throw new Error( + 'Minimum value must be less than or equal to the maximum value' + ); + } + + if ($max === $min) { + return (int) $min; + } + + /** + * Initialize variables to 0 + * + * We want to store: + * $bytes => the number of random bytes we need + * $mask => an integer bitmask (for use with the &) operator + * so we can minimize the number of discards + */ + $attempts = $bits = $bytes = $mask = $valueShift = 0; + /** @var int $attempts */ + /** @var int $bits */ + /** @var int $bytes */ + /** @var int $mask */ + /** @var int $valueShift */ + + /** + * At this point, $range is a positive number greater than 0. It might + * overflow, however, if $max - $min > PHP_INT_MAX. PHP will cast it to + * a float and we will lose some precision. + * + * @var int|float $range + */ + $range = $max - $min; + + /** + * Test for integer overflow: + */ + if (!is_int($range)) { + + /** + * Still safely calculate wider ranges. + * Provided by @CodesInChaos, @oittaa + * + * @ref https://gist.github.com/CodesInChaos/03f9ea0b58e8b2b8d435 + * + * We use ~0 as a mask in this case because it generates all 1s + * + * @ref https://eval.in/400356 (32-bit) + * @ref http://3v4l.org/XX9r5 (64-bit) + */ + $bytes = PHP_INT_SIZE; + /** @var int $mask */ + $mask = ~0; + + } else { + + /** + * $bits is effectively ceil(log($range, 2)) without dealing with + * type juggling + */ + while ($range > 0) { + if ($bits % 8 === 0) { + ++$bytes; + } + ++$bits; + $range >>= 1; + /** @var int $mask */ + $mask = $mask << 1 | 1; + } + $valueShift = $min; + } + + /** @var int $val */ + $val = 0; + /** + * Now that we have our parameters set up, let's begin generating + * random integers until one falls between $min and $max + */ + /** @psalm-suppress RedundantCondition */ + do { + /** + * The rejection probability is at most 0.5, so this corresponds + * to a failure probability of 2^-128 for a working RNG + */ + if ($attempts > 128) { + throw new Exception( + 'random_int: RNG is broken - too many rejections' + ); + } + + /** + * Let's grab the necessary number of random bytes + */ + $randomByteString = random_bytes($bytes); + + /** + * Let's turn $randomByteString into an integer + * + * This uses bitwise operators (<< and |) to build an integer + * out of the values extracted from ord() + * + * Example: [9F] | [6D] | [32] | [0C] => + * 159 + 27904 + 3276800 + 201326592 => + * 204631455 + */ + $val &= 0; + for ($i = 0; $i < $bytes; ++$i) { + $val |= ord($randomByteString[$i]) << ($i * 8); + } + /** @var int $val */ + + /** + * Apply mask + */ + $val &= $mask; + $val += $valueShift; + + ++$attempts; + /** + * If $val overflows to a floating point number, + * ... or is larger than $max, + * ... or smaller than $min, + * then try again. + */ + } while (!is_int($val) || $val > $max || $val < $min); + + return (int) $val; + } +} diff --git a/inc/_init_login.inc.php b/inc/_init_login.inc.php index 96546e1b9b3..6b8e2d949c2 100644 --- a/inc/_init_login.inc.php +++ b/inc/_init_login.inc.php @@ -267,12 +267,12 @@ } $current_User = & $UserCache->get_by_login($login); // check and don't login if the current user account was closed - if( $current_User->check_status( 'is_closed' ) ) + if( check_user_status( 'is_closed' ) ) { // user account was closed unset( $current_User ); $login_error = T_('This account is closed. You cannot log in.'); } - elseif( $Settings->get('system_lock') && !$current_User->check_perm( 'users', 'edit' ) ) + elseif( $Settings->get('system_lock') && ! check_user_perm( 'users', 'edit' ) ) { // System is locked for maintenance and current user has no permission to log in this mode unset( $current_User ); $login_error = T_('You cannot log in at this time because the system is under maintenance. Please try again in a few moments.'); @@ -299,7 +299,7 @@ } } - if( $Settings->get('system_lock') && $current_User->check_perm( 'users', 'edit' ) ) + if( $Settings->get('system_lock') && check_user_perm( 'users', 'edit' ) ) { // System is locked for maintenance but current user has permission to log in, Display a message about this mode $Messages->add( T_('The site is currently locked for maintenance.').' '.sprintf( T_('Click here to access lock settings.'), 'href="'.$admin_url.'?ctrl=tools"' ), 'warning' ); } @@ -386,7 +386,7 @@ if( $Settings->get('system_lock') ) { // System is locked for maintenance - if( $current_User->check_perm( 'users', 'edit' ) ) + if( check_user_perm( 'users', 'edit' ) ) { // Current user is a "super admin" if( ! $Messages->count() ) { // If there are no other messages yet, display a warning about the system lock diff --git a/inc/_init_session.inc.php b/inc/_init_session.inc.php index be86578b9e3..37a737a05e0 100644 --- a/inc/_init_session.inc.php +++ b/inc/_init_session.inc.php @@ -26,7 +26,7 @@ load_funcs( '_core/_url.funcs.php' ); if( !empty($is_admin_page) ) { // Make sure we are calling the right page (on the right domain) to make sure that session cookie goes through: - if( ! is_same_url( $ReqHost.$ReqPath, $admin_url, true ) ) + if( ! is_same_url( $ReqHost.$ReqPath, get_admin_url(), true ) ) { // The requested URL does not look like it's under the admin URL... if( is_same_url( $ReqHost.$ReqPath, $baseurl.'admin.php', true ) ) { // Permanent redirect from obsolete admin.php url: diff --git a/inc/antispam/antispam.ctrl.php b/inc/antispam/antispam.ctrl.php index bdfbb4ad0e2..b1ba09d79d7 100644 --- a/inc/antispam/antispam.ctrl.php +++ b/inc/antispam/antispam.ctrl.php @@ -53,8 +53,8 @@ } // Check permission: -if( ! ( $current_User->check_perm( 'admin', 'normal' ) && $current_User->check_perm( 'spamblacklist', 'view' ) ) && - ! ( $current_User->check_perm( 'users', 'moderate' ) && ( ( $tab3 == 'tools' && $tool == 'whois' && empty( $action ) ) || $action == 'whois' ) ) ) +if( ! ( check_user_perm( 'admin', 'normal' ) && check_user_perm( 'spamblacklist', 'view' ) ) && + ! ( check_user_perm( 'users', 'moderate' ) && ( ( $tab3 == 'tools' && $tool == 'whois' && empty( $action ) ) || $action == 'whois' ) ) ) { debug_die( sprintf( /* %s is the application name, usually "b2evolution" */ TB_('Group/user permission denied by %s!'), $app_name ) ); } @@ -79,7 +79,7 @@ $Session->assert_received_crumb( 'antispam' ); // Check permission: - $current_User->check_perm( 'spamblacklist', 'edit', true ); // TODO: This should become different for 'edit'/'add' perm level - check for 'add' here. + check_user_perm( 'spamblacklist', 'edit', true ); // TODO: This should become different for 'edit'/'add' perm level - check for 'add' here. $keyword = utf8_substr( $keyword, 0, 80 ); param( 'delhits', 'integer', 0 ); @@ -188,7 +188,7 @@ $Session->assert_received_crumb( 'antispam' ); // Check permission: - $current_User->check_perm( 'spamblacklist', 'edit', true ); + check_user_perm( 'spamblacklist', 'edit', true ); param( 'hit_ID', 'integer', true ); // Required! $Messages->add( sprintf( TB_('Removing entry #%d from the ban list...'), $hit_ID), 'note' ); @@ -203,7 +203,7 @@ $Session->assert_received_crumb( 'antispam' ); // Check permission: - $current_User->check_perm( 'spamblacklist', 'edit', true ); + check_user_perm( 'spamblacklist', 'edit', true ); // Report this keyword as abuse: antispam_report_abuse( $keyword ); @@ -217,7 +217,7 @@ $Session->assert_received_crumb( 'antispam' ); // Check permission: - $current_User->check_perm( 'spamblacklist', 'edit', true ); + check_user_perm( 'spamblacklist', 'edit', true ); ob_start(); antispam_poll_abuse(); @@ -230,7 +230,7 @@ $Session->assert_received_crumb( 'antispam' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // fp> Restore defaults has been removed because it's extra maintenance work and no real benefit to the user. @@ -298,7 +298,7 @@ $Session->assert_received_crumb( 'antispam' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); $keywords = $DB->get_col( 'SELECT askw_string FROM T_antispam__keyword' ); $keywords = array_chunk( $keywords, 100 ); @@ -333,7 +333,7 @@ $Session->assert_received_crumb( 'antispam' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); $keywords = $DB->get_col( 'SELECT askw_string FROM T_antispam__keyword' ); $keywords = array_chunk( $keywords, 100 ); @@ -367,7 +367,7 @@ $Session->assert_received_crumb( 'iprange' ); // Check permission: - $current_User->check_perm( 'spamblacklist', 'edit', true ); + check_user_perm( 'spamblacklist', 'edit', true ); $edited_IPRange = new IPRange(); @@ -392,7 +392,7 @@ $Session->assert_received_crumb( 'iprange' ); // Check permission: - $current_User->check_perm( 'spamblacklist', 'edit', true ); + check_user_perm( 'spamblacklist', 'edit', true ); // Make sure we got an iprange_ID: param( 'iprange_ID', 'integer', true ); @@ -418,7 +418,7 @@ $Session->assert_received_crumb( 'iprange' ); // Check permission: - $current_User->check_perm( 'spamblacklist', 'edit', true ); + check_user_perm( 'spamblacklist', 'edit', true ); // Make sure we got an iprange_ID: param( 'iprange_ID', 'integer', true ); @@ -440,7 +440,7 @@ $Session->assert_received_crumb( 'antispam' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); $bankruptcy_blogs_IDs = param( 'bankruptcy_blogs', 'array:integer', array() ); @@ -484,7 +484,7 @@ if( isset( $collections_Module ) ) { // Display list of blogs: - if( $current_User->check_perm( 'stats', 'view' ) ) + if( check_user_perm( 'stats', 'view' ) ) { $AdminUI->set_coll_list_params( 'stats', 'view', array( 'ctrl' => 'antispam', 'tab' => $tab, 'tab3' => $tab3 ), TB_('All'), $admin_url.'?ctrl=antispam&tab='.$tab.'&tab3='.$tab3.'&blog=0', NULL, false, true ); @@ -538,9 +538,9 @@ case 'ipranges': if( empty( $action ) ) { // View a list of IP ranges - require_js( 'jquery/jquery.jeditable.js', 'rsc_url' ); + require_js_defer( 'customized:jquery/jeditable/jquery.jeditable.js', 'rsc_url' ); } - elseif( ! $current_User->check_perm( 'spamblacklist', 'edit' ) ) + elseif( ! check_user_perm( 'spamblacklist', 'edit' ) ) { // Check permission to create/edit IP range $Messages->add( TB_('You have no permission to edit this IP range!'), 'error' ); $action = ''; @@ -560,9 +560,9 @@ break; case 'countries': - if( $current_User->check_perm( 'options', 'edit' ) ) + if( check_user_perm( 'options', 'edit' ) ) { - require_js( 'jquery/jquery.jeditable.js' ); + require_js_defer( 'customized:jquery/jeditable/jquery.jeditable.js' ); } // Set an url for manual page: @@ -574,12 +574,12 @@ case 'domains': load_funcs('sessions/model/_hitlog.funcs.php'); $AdminUI->breadcrumbpath_add( TB_('Referring domains'), '?ctrl=antispam&tab3='.$tab3 ); - if( $current_User->check_perm( 'stats', 'edit' ) ) + if( check_user_perm( 'stats', 'edit' ) ) { - require_js( 'jquery/jquery.jeditable.js' ); + require_js_defer( 'customized:jquery/jeditable/jquery.jeditable.js' ); } // Load jquery UI to highlight cell on change domain type - require_js( '#jqueryUI#' ); + require_js_defer( '#jqueryUI#' ); // Used for edit form $tab_from = 'antispam'; $blog = 0; // Don't restrict domains by blog ID on this controller @@ -623,7 +623,7 @@ // Check permission: if( $tool != 'whois' ) { - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); } switch( $tool ) diff --git a/inc/antispam/model/_antispam.funcs.php b/inc/antispam/model/_antispam.funcs.php index 17148f0a5a1..9350b6bfefd 100644 --- a/inc/antispam/model/_antispam.funcs.php +++ b/inc/antispam/model/_antispam.funcs.php @@ -439,8 +439,6 @@ function get_ban_domain( $url ) */ function blog_restrict( $delstatuses ) { - global $current_User; - if( empty( $delstatuses ) ) { // none of the statuses should be deleted return ' AND false'; @@ -448,7 +446,7 @@ function blog_restrict( $delstatuses ) // asimo> Currently only global blogs editall permission gives rights to permanently delete comments // Probably this function must be changed when the advanced collection perms will be finished - if( !$current_User->check_perm( 'blogs', 'editall', false ) ) + if( ! check_user_perm( 'blogs', 'editall', false ) ) { // User has permission to permanently delete comments on this blog return ' AND false'; } @@ -476,8 +474,6 @@ function blog_restrict( $delstatuses ) */ function echo_affected_comments( $affected_comments, $status, $keyword, $noperms_count ) { - global $current_User; - $num_comments = count( $affected_comments ); if( $num_comments == 0 ) { @@ -493,7 +489,7 @@ function echo_affected_comments( $affected_comments, $status, $keyword, $noperms } echo '

    '; - if( $current_User->check_perm( 'blogs', 'editall', false ) ) + if( check_user_perm( 'blogs', 'editall', false ) ) { // current User has rights to permanently delete comments $checkbox_status = 'checked="checked"'; } @@ -1357,7 +1353,7 @@ function antispam_increase_counter( $counter_name ) */ function antispam_get_whois( $query = NULL, $window_height = NULL ) { - global $current_User, $admin_url; + global $admin_url; load_class('_ext/phpwhois/whois.main.php', 'whois' ); @@ -1421,7 +1417,7 @@ function antispam_get_whois( $query = NULL, $window_height = NULL ) } // Make IP ranges clickable - if( $current_User->check_perm( 'spamblacklist', 'view' ) && + if( check_user_perm( 'spamblacklist', 'view' ) && preg_match_all( '#(?<=\:)(\s*)(\b(?:(?:25[0-5]|[0-9]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9])\.){3}(?:25[0-5]|[0-9]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9])\s?-\s?(?:(?:25[0-5]|[0-9]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9])\.){3}(?:25[0-5]|[0-9]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9])\b)#', $result['rawdata'][$i], $matches ) ) { $aipr_status_titles = aipr_status_titles(); @@ -1440,7 +1436,7 @@ function antispam_get_whois( $query = NULL, $window_height = NULL ) $whois_IPs = explode( '-', $ip_range_text ); $whois_IP_start = isset( $whois_IPs[0] ) ? trim( $whois_IPs[0] ) : ''; $whois_IP_end = isset( $whois_IPs[1] ) ? trim( $whois_IPs[1] ) : ''; - if( $current_User->check_perm( 'spamblacklist', 'edit' ) ) + if( check_user_perm( 'spamblacklist', 'edit' ) ) { // If current user has a permission to edit IP ranges: if( $IPRange ) { // If IP range is found in DB: diff --git a/inc/antispam/views/_antispam_ban.form.php b/inc/antispam/views/_antispam_ban.form.php index 02f3161c4f0..dc837318bcd 100644 --- a/inc/antispam/views/_antispam_ban.form.php +++ b/inc/antispam/views/_antispam_ban.form.php @@ -17,7 +17,7 @@ */ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); -global $Settings, $current_User, $display_mode, $antispamsrv_host, $antispamsrv_tos_url; +global $Settings, $display_mode, $antispamsrv_host, $antispamsrv_tos_url; global $keyword; global $row_stats; // for hit functions @@ -157,7 +157,7 @@ { // This comment was already deleted continue; } - if( !$current_User->check_perm( 'comment!CURSTATUS', 'edit', false, $affected_Comment ) ) + if( ! check_user_perm( 'comment!CURSTATUS', 'edit', false, $affected_Comment ) ) { // no permission to delete $no_perms_count[$comment_status] = $no_perms_count[$comment_status] + 1; continue; @@ -193,7 +193,7 @@ $res_affected_users = $DB->get_results( $sql, OBJECT, 'Find matching users' ); if( $DB->num_rows != 0 ) { - if( ! $current_User->check_perm( 'users', 'view', false ) ) + if( ! check_user_perm( 'users', 'view', false ) ) { // current user has no permission to view users printf( '

    '.TB_('There are %d matching users but you have no permission to see them.').'

    ', $DB->num_rows ); } @@ -211,7 +211,7 @@ check_perm( 'users', 'edit', false ); + $current_user_edit_perm = check_user_perm( 'users', 'edit', false ); foreach( $res_affected_users as $row_stats ) { // Display affected users $affected_User = new User($row_stats); diff --git a/inc/antispam/views/_antispam_ipranges.view.php b/inc/antispam/views/_antispam_ipranges.view.php index 5916f9596f1..0db2ad59a35 100644 --- a/inc/antispam/views/_antispam_ipranges.view.php +++ b/inc/antispam/views/_antispam_ipranges.view.php @@ -91,7 +91,7 @@ function filter_email_blocked( & $Form ) $Results->cols[] = array( 'th' => T_('Status'), - 'td' => /* Check permission: */$current_User->check_perm( 'spamblacklist', 'edit' ) ? + 'td' => /* Check permission: */check_user_perm( 'spamblacklist', 'edit' ) ? /* Current user can edit IP ranges */'%aipr_status_title( #aipr_status# )%' : /* No edit, only view the status */'%aipr_status_title( #aipr_status# )%', 'td_class' => 'jeditable_cell iprange_status_edit', @@ -101,7 +101,7 @@ function filter_email_blocked( & $Form ) $Results->cols[] = array( 'th' => T_('IP Range Start'), - 'td' => /* Check permission: */$current_User->check_perm( 'spamblacklist', 'edit' ) ? + 'td' => /* Check permission: */check_user_perm( 'spamblacklist', 'edit' ) ? /* Current user can edit IP ranges */'%int2ip( #aipr_IPv4start# )%' : /* No edit, only view the IP address */'%int2ip( #aipr_IPv4start# )%', 'order' => 'aipr_IPv4start', @@ -109,7 +109,7 @@ function filter_email_blocked( & $Form ) $Results->cols[] = array( 'th' => T_('IP Range End'), - 'td' => /* Check permission: */$current_User->check_perm( 'spamblacklist', 'edit' ) ? + 'td' => /* Check permission: */check_user_perm( 'spamblacklist', 'edit' ) ? /* Current user can edit IP ranges */'%int2ip( #aipr_IPv4end# )%' : /* No edit, only view the IP address */'%int2ip( #aipr_IPv4end# )%', 'order' => 'aipr_IPv4end', @@ -142,7 +142,7 @@ function filter_email_blocked( & $Form ) 'column' => 'aipr_IPv4start', 'Results' => $Results ) ); -if( $current_User->check_perm( 'spamblacklist', 'edit' ) ) +if( check_user_perm( 'spamblacklist', 'edit' ) ) { // Check permission to edit IP ranges: /** @@ -175,14 +175,14 @@ function antispam_ipranges_actions( $aipr_ID, $tab_param ) ); } -if( $current_User->check_perm( 'spamblacklist', 'edit' ) ) +if( check_user_perm( 'spamblacklist', 'edit' ) ) { // Check permission to edit IP ranges: $Results->global_icon( T_('Add a new IP range...'), 'new', regenerate_url( 'action', 'action=iprange_new'), T_('New IP range').' »', 3, 4, array( 'class' => 'action_icon btn-primary' ) ); } $Results->display(); -if( $current_User->check_perm( 'spamblacklist', 'edit' ) ) +if( check_user_perm( 'spamblacklist', 'edit' ) ) { // Check permission to edit IP ranges: // Print JS to edit status of IP range echo_editable_column_js( array( diff --git a/inc/antispam/views/_antispam_list.view.php b/inc/antispam/views/_antispam_list.view.php index 97411cbb00c..fa9cf20f343 100644 --- a/inc/antispam/views/_antispam_list.view.php +++ b/inc/antispam/views/_antispam_list.view.php @@ -24,7 +24,7 @@ } echo '

    '.T_('User generated content containing keywords from the Antispam Blacklist will be rejected.'); -if( $current_User->check_perm( 'spamblacklist', 'edit' ) ) +if( check_user_perm( 'spamblacklist', 'edit' ) ) { global $antispamsrv_tos_url; echo '
    '.sprintf( T_('You can share your keywords with and retrieve keywords from the Central Antispam Blacklist service Terms of service'), 'href="'.$antispamsrv_tos_url.'"' ); @@ -32,7 +32,7 @@ echo '

    '; // ADD KEYWORD FORM: -if( $current_User->check_perm( 'spamblacklist', 'edit' ) ) // TODO: check for 'add' here once it's mature. +if( check_user_perm( 'spamblacklist', 'edit' ) ) // TODO: check for 'add' here once it's mature. { // add keyword or domain global $keyword; @@ -77,7 +77,7 @@ $Results->title = T_('Banned keywords blacklist'); -if( $current_User->check_perm( 'spamblacklist', 'edit' ) ) +if( check_user_perm( 'spamblacklist', 'edit' ) ) { // Allow to request keywords from Central Antispam if current user has a permission: global $admin_url; $Results->global_icon( T_('Request update from Central Antispam Blacklist'), '', $admin_url.'?ctrl=antispam&action=poll&'.url_crumb( 'antispam' ), T_('Request update from Central Antispam Blacklist'), 0, 0, array( 'class' => 'action_icon btn-primary' ) ); @@ -145,7 +145,7 @@ function antispam_source2( & $row ) ); // Check if we need to display more: -if( $current_User->check_perm( 'spamblacklist', 'edit' ) ) +if( check_user_perm( 'spamblacklist', 'edit' ) ) { // User can edit, spamlist: add controls to output columns: // Add a column for actions: diff --git a/inc/antispam/views/_antispam_settings.form.php b/inc/antispam/views/_antispam_settings.form.php index 3d9c4e51da6..d50efba406b 100644 --- a/inc/antispam/views/_antispam_settings.form.php +++ b/inc/antispam/views/_antispam_settings.form.php @@ -83,7 +83,7 @@ $Form->end_fieldset(); -if( $current_User->check_perm( 'options', 'edit' ) ) +if( check_user_perm( 'options', 'edit' ) ) { $Form->end_form( array( array( 'submit', 'submit', TB_('Save Changes!'), 'SaveButton', 'data-shortcut' => 'ctrl+s,command+s,ctrl+enter,command+enter' ), diff --git a/inc/automations/automations.ctrl.php b/inc/automations/automations.ctrl.php index 32ca6e07df1..e7e3217a3e3 100644 --- a/inc/automations/automations.ctrl.php +++ b/inc/automations/automations.ctrl.php @@ -19,8 +19,8 @@ load_class( 'automations/model/_automationstep.class.php', 'AutomationStep' ); // Check permission: -$current_User->check_perm( 'admin', 'normal', true ); -$current_User->check_perm( 'options', 'view', true ); +check_user_perm( 'admin', 'normal', true ); +check_user_perm( 'options', 'view', true ); param_action( '', true ); param( 'display_mode', 'string', 'normal' ); @@ -56,7 +56,7 @@ // New Automation form: // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Create object of new Automation: $edited_Automation = new Automation(); @@ -68,7 +68,7 @@ // Edit Automation/Step forms: // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); if( $action == 'copy_step' ) { // Clear an order of the duplicating step in order to set this automatically right below current one: @@ -85,7 +85,7 @@ // New Automation Step form: // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Create object of new Automation: $edited_AutomationStep = new AutomationStep(); @@ -105,7 +105,7 @@ $Session->assert_received_crumb( 'automation' ); // Check that current user has permission to create automations: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // load data from request if( $edited_Automation->load_from_Request() ) @@ -143,7 +143,7 @@ $Session->assert_received_crumb( 'automation' ); // Check that current user has permission to edit automations: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure we got an autm_ID: param( 'autm_ID', 'integer', true ); @@ -169,7 +169,7 @@ $Session->assert_received_crumb( 'automation' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure we got an autm_ID: param( 'autm_ID', 'integer', true ); @@ -202,7 +202,7 @@ $Session->assert_received_crumb( 'automation' ); // Check that current user has permission to edit automations: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure we got an autm_ID: param( 'autm_ID', 'integer', true ); @@ -248,7 +248,7 @@ $Session->assert_received_crumb( 'automation' ); // Check that current user has permission to edit automations: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure we got IDs: param( 'autm_ID', 'integer', true ); @@ -307,7 +307,7 @@ $Session->assert_received_crumb( 'automationstep' ); // Check that current user has permission to create automation steps: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); if( ! $edited_AutomationStep->can_be_modified() ) { // If step cannot be modified currently @@ -392,7 +392,7 @@ $Session->assert_received_crumb( 'automationstep' ); // Check that current user has permission to create automation steps: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); $edited_AutomationStep = new AutomationStep(); @@ -423,7 +423,7 @@ $Session->assert_received_crumb( 'automationstep' ); // Check that current user has permission to create automation steps: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); $duplicated_step_ID = $edited_AutomationStep->ID; $duplicated_step_order = $edited_AutomationStep->get( 'order' ); @@ -483,7 +483,7 @@ $Session->assert_received_crumb( 'automationstep' ); // Check that current user has permission to edit automation steps: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure we got an step_ID: param( 'step_ID', 'integer', true ); @@ -514,7 +514,7 @@ $Session->assert_received_crumb( 'automationstep' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); param( 'pos', 'array:integer' ); @@ -537,7 +537,7 @@ $Session->assert_received_crumb( 'automationstep' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); param( 'connection_type', 'string', true ); @@ -579,7 +579,7 @@ $Session->assert_received_crumb( 'automationstep' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Reset positions of all steps of the edited Automation: $DB->query( 'UPDATE T_automation__step @@ -600,7 +600,7 @@ $Session->assert_received_crumb( 'automationstep' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure we got an autm_ID: param( 'autm_ID', 'integer', true ); @@ -631,7 +631,7 @@ $Session->assert_received_crumb( 'automation' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); param( 'user_ID', 'integer', true ); $UserCache = & get_UserCache(); @@ -670,7 +670,7 @@ $Session->assert_received_crumb( 'automation' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); param( 'user_ID', 'integer', true ); $UserCache = & get_UserCache(); @@ -702,7 +702,7 @@ $Session->assert_received_crumb( 'automation' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); param( 'user_ID', 'integer', true ); $UserCache = & get_UserCache(); @@ -791,10 +791,10 @@ $AdminUI->set_page_manual_link( 'automation-diagram-view' ); $AdminUI->set_path( 'email', 'automations', 'diagram' ); // Load files to draw diagram by plugin jsPlumb: - require_js( 'jquery/jsplumb/jsplumb.min.js', 'rsc_url' ); - require_css( 'jquery/jsplumb/jsplumbtoolkit-defaults.css', 'rsc_url' ); - require_css( 'jquery/jsplumb/jsplumbtoolkit-b2evo.css', 'rsc_url' ); - require_js( 'jquery/jquery.panzoom.min.js', 'rsc_url' ); + require_js_defer( 'ext:jquery/jsplumb/js/jsplumb.min.js', 'rsc_url' ); + require_css( 'ext:jquery/jsplumb/css/jsplumbtoolkit-defaults.css', 'rsc_url' ); + require_css( 'ext:jquery/jsplumb/css/jsplumbtoolkit-b2evo.css', 'rsc_url' ); + require_js_defer( 'ext:jquery/panzoom/js/jquery.panzoom.min.js', 'rsc_url' ); break; default: diff --git a/inc/automations/model/_automation.funcs.php b/inc/automations/model/_automation.funcs.php index 1e96f633ea9..36e892b6a78 100644 --- a/inc/automations/model/_automation.funcs.php +++ b/inc/automations/model/_automation.funcs.php @@ -76,9 +76,7 @@ function autm_get_status_title( $status ) */ function autm_td_tied_lists( $newsletters ) { - global $current_User; - - if( $current_User->check_perm( 'emails', 'edit' ) ) + if( check_user_perm( 'emails', 'edit' ) ) { // Make icon to action link if current User has a perm to edit this: global $admin_url; $r = ''; @@ -181,11 +179,11 @@ function autm_td_users_actions( $autm_ID, $user_ID, $user_login, $step_ID, $step */ function autm_td_status( $autm_ID, $autm_status, $url_params = '' ) { - global $admin_url, $current_User; + global $admin_url; $r = autm_get_status_title( $autm_status ); - if( is_logged_in() && $current_User->check_perm( 'options', 'edit' ) ) + if( check_user_perm( 'options', 'edit' ) ) { // Display action icon to toggle automation status: $r .= ' '.action_icon( '', ( $autm_status == 'active' ? 'pause' : 'play' ), $admin_url.'?ctrl=automations&action='.( $autm_status == 'active' ? 'status_paused' : 'status_active' ) @@ -397,12 +395,12 @@ function step_td_num_users_queued( $step_ID, $autm_ID, $num_users_queued, $step_ */ function step_td_label( $step_ID, $step_label, $step_type, $step_info ) { - global $current_User, $admin_url; + global $admin_url; $step_type_title = step_get_type_title( $step_type ); // Display step type title as: - $r = $current_User->check_perm( 'options', 'edit' ) + $r = check_user_perm( 'options', 'edit' ) // link to edit page if current user has a permission: ? ''.$step_type_title.': ' // plain text if current user has no permission: @@ -412,7 +410,7 @@ function step_td_label( $step_ID, $step_label, $step_type, $step_info ) { case 'send_campaign': // Display email campaign title as: - $r .= $current_User->check_perm( 'emails', 'edit' ) + $r .= check_user_perm( 'emails', 'edit' ) // link to edit page if current user has a permission: ? ''.$step_label.'' // plain text if current user has no permission: @@ -422,7 +420,7 @@ function step_td_label( $step_ID, $step_label, $step_type, $step_info ) case 'subscribe': case 'unsubscribe': // Display newsletter name as: - $r .= $current_User->check_perm( 'emails', 'edit' ) + $r .= check_user_perm( 'emails', 'edit' ) // link to edit page if current user has a permission: ? ''.$step_label.'' // plain text if current user has no permission: @@ -431,7 +429,7 @@ function step_td_label( $step_ID, $step_label, $step_type, $step_info ) case 'start_automation': // Display automation name as: - $r .= $current_User->check_perm( 'options', 'edit' ) + $r .= check_user_perm( 'options', 'edit' ) // link to edit page if current user has a permission: ? ''.$step_label.'' // plain text if current user has no permission: @@ -439,7 +437,7 @@ function step_td_label( $step_ID, $step_label, $step_type, $step_info ) break; default: - $r = $current_User->check_perm( 'options', 'edit' ) + $r = check_user_perm( 'options', 'edit' ) // link to edit page if current user has a permission: ? ''.$step_type_title.': '.$step_label.'' // plain text if current user has no permission: @@ -576,7 +574,7 @@ function echo_requeue_automation_js() */ function automation_results_block( $params = array() ) { - global $admin_url, $current_User, $DB; + global $admin_url, $DB; $params = array_merge( array( 'enlt_ID' => NULL, // Newsletter ID @@ -614,7 +612,7 @@ function automation_results_block( $params = array() ) $Results = new Results( $SQL->get(), $params['results_prefix'], 'A', NULL, $count_SQL->get() ); - if( $params['display_create_button'] && $current_User->check_perm( 'options', 'edit' ) ) + if( $params['display_create_button'] && check_user_perm( 'options', 'edit' ) ) { // User must has a permission to add new automation: //$Results->global_icon( TB_('New automation'), 'new', regenerate_url( 'action', 'action=new' ), TB_('New automation').' »', 3, 4, array( 'class' => 'action_icon btn-primary' ) ); $Results->global_icon( TB_('New automation'), 'new', $admin_url.'?ctrl=automations&action=new'.( isset( $params['enlt_ID'] ) ? '&enlt_ID='.$params['enlt_ID'] : '' ), TB_('New automation').' »', 3, 4, array( 'class' => 'action_icon btn-primary' ) ); @@ -633,7 +631,7 @@ function automation_results_block( $params = array() ) $Results->cols[] = array( 'th' => TB_('Name'), 'order' => 'autm_name', - 'td' => ( $current_User->check_perm( 'options', 'edit' ) + 'td' => ( check_user_perm( 'options', 'edit' ) ? '$autm_name$' : '$autm_name$' ), ); @@ -661,7 +659,7 @@ function automation_results_block( $params = array() ) 'td_class' => 'shrinkwrap', ); - if( $current_User->check_perm( 'options', 'edit' ) ) + if( check_user_perm( 'options', 'edit' ) ) { // Display actions column only if current user has a permission to edit options: $Results->cols[] = array( 'th' => TB_('Actions'), diff --git a/inc/central_antispam/_central_antispam.init.php b/inc/central_antispam/_central_antispam.init.php index 2dee70d505d..8905ded9a4d 100644 --- a/inc/central_antispam/_central_antispam.init.php +++ b/inc/central_antispam/_central_antispam.init.php @@ -105,9 +105,9 @@ function init() */ function build_menu_3() { - global $AdminUI, $admin_url, $current_User; + global $AdminUI, $admin_url; - if( ! is_logged_in() || ! $current_User->check_perm( 'centralantispam', 'view' ) ) + if( ! check_user_perm( 'centralantispam', 'view' ) ) { // Don't display menu if current user has no access to central antispam: return; } @@ -258,7 +258,7 @@ function upgrade_b2evo_tables() */ function handle_htsrv_action() { - global $current_User, $DB, $Session, $localtimenow, $debug, $debug_jslog; + global $DB, $Session, $localtimenow, $debug, $debug_jslog; if( ! is_logged_in() ) { // User must be logged in: @@ -282,7 +282,7 @@ function handle_htsrv_action() $Session->assert_received_crumb( 'cakeyword' ); // Check permission: - $current_User->check_perm( 'centralantispam', 'edit', true ); + check_user_perm( 'centralantispam', 'edit', true ); $new_status = param( 'new_status', 'string' ); $cakw_ID = param( 'cakw_ID', 'integer', true ); @@ -302,7 +302,7 @@ function handle_htsrv_action() $Session->assert_received_crumb( 'casource' ); // Check permission: - $current_User->check_perm( 'centralantispam', 'edit', true ); + check_user_perm( 'centralantispam', 'edit', true ); $new_status = param( 'new_status', 'string' ); $casrc_ID = param( 'casrc_ID', 'integer', true ); diff --git a/inc/central_antispam/central_antispam.ctrl.php b/inc/central_antispam/central_antispam.ctrl.php index bbca020dbcc..94799d3e9d4 100644 --- a/inc/central_antispam/central_antispam.ctrl.php +++ b/inc/central_antispam/central_antispam.ctrl.php @@ -18,7 +18,7 @@ load_class( 'central_antispam/model/_source.class.php', 'CaSource' ); // Check permission: -$current_User->check_perm( 'centralantispam', 'view', true ); +check_user_perm( 'centralantispam', 'view', true ); param_action( '', true ); param( 'tab', 'string', 'keywords', true ); @@ -59,7 +59,7 @@ { case 'keyword_new': // Check permission: - $current_User->check_perm( 'centralantispam', 'create', true ); + check_user_perm( 'centralantispam', 'create', true ); if( ! isset( $edited_CaKeyword ) ) { // We don't have a model to use, start with blank object: @@ -75,7 +75,7 @@ $Session->assert_received_crumb( 'cakeyword' ); // Check permission: - $current_User->check_perm( 'centralantispam', 'edit', true ); + check_user_perm( 'centralantispam', 'edit', true ); // load data from request if( $edited_CaKeyword->load_from_Request() ) @@ -142,7 +142,7 @@ $Session->assert_received_crumb( 'cakeyword' ); // Check permission: - $current_User->check_perm( 'centralantispam', 'edit', true ); + check_user_perm( 'centralantispam', 'edit', true ); // load data from request if( $edited_CaKeyword->load_from_Request() ) @@ -171,7 +171,7 @@ $Session->assert_received_crumb( 'casource' ); // Check permission: - $current_User->check_perm( 'centralantispam', 'edit', true ); + check_user_perm( 'centralantispam', 'edit', true ); // Load data from request: if( $edited_CaSource->load_from_Request() ) @@ -193,7 +193,7 @@ $Session->assert_received_crumb( 'cakeywordsimport' ); // Check permission: - $current_User->check_perm( 'centralantispam', 'edit', true ); + check_user_perm( 'centralantispam', 'edit', true ); $import_keywords = param( 'import_keywords', 'array:string' ); @@ -312,19 +312,19 @@ // Initialize date picker: init_datepicker_js(); } - if( empty( $action ) && $current_User->check_perm( 'centralantispam', 'edit' ) ) + if( empty( $action ) && check_user_perm( 'centralantispam', 'edit' ) ) { // Load JS to edit keyword status from list: - require_js( '#jquery#', 'rsc_url' ); - require_js( 'jquery/jquery.jeditable.js', 'rsc_url' ); + require_js_defer( '#jquery#', 'rsc_url' ); + require_js_defer( 'customized:jquery/jeditable/jquery.jeditable.js', 'rsc_url' ); } break; case 'reporters': $AdminUI->breadcrumbpath_add( TB_('Reporters'), $admin_url.'?ctrl=central_antispam&tab='.$tab ); - if( empty( $action ) && $current_User->check_perm( 'centralantispam', 'edit' ) ) + if( empty( $action ) && check_user_perm( 'centralantispam', 'edit' ) ) { // Load JS to edit source status from list: - require_js( '#jquery#', 'rsc_url' ); - require_js( 'jquery/jquery.jeditable.js', 'rsc_url' ); + require_js_defer( '#jquery#', 'rsc_url' ); + require_js_defer( 'customized:jquery/jeditable/jquery.jeditable.js', 'rsc_url' ); } break; } diff --git a/inc/central_antispam/views/_keywords.form.php b/inc/central_antispam/views/_keywords.form.php index 364a974b095..b82be0152c3 100644 --- a/inc/central_antispam/views/_keywords.form.php +++ b/inc/central_antispam/views/_keywords.form.php @@ -74,9 +74,7 @@ function get_link_for_url( $id, $url ) { - global $current_User; - - if( $current_User->check_perm( 'centralantispam', 'edit' ) ) + if( check_user_perm( 'centralantispam', 'edit' ) ) { // Not reserved id AND current User has permission to edit the global settings $ret_url = ''.$url.''; } diff --git a/inc/central_antispam/views/_keywords.view.php b/inc/central_antispam/views/_keywords.view.php index 3301a07a203..7c0a71b3352 100644 --- a/inc/central_antispam/views/_keywords.view.php +++ b/inc/central_antispam/views/_keywords.view.php @@ -23,7 +23,7 @@ */ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); -global $central_antispam_Module, $UserSettings, $admin_url, $current_User; +global $central_antispam_Module, $UserSettings, $admin_url; $keywords = param( 'keywords', 'string', '', true ); $status = param( 'status', 'string', '', true ); @@ -105,7 +105,7 @@ function filter_central_antispam( & $Form ) 'order' => 'cakw_status', 'th_class' => 'shrinkwrap', 'td_class' => 'jeditable_cell cakeyword_status_edit', - 'td' => /* Check permission: */$current_User->check_perm( 'centralantispam', 'edit' ) ? + 'td' => /* Check permission: */check_user_perm( 'centralantispam', 'edit' ) ? /* Current user can edit keyword */'%ca_get_keyword_status_title( #cakw_status# )%' : /* No edit, only view the status */'%ca_get_keyword_status_title( #cakw_status# )%', 'extra' => array ( 'style' => 'background-color: %ca_get_keyword_status_color( "#cakw_status#" )%;color:#FFF', 'format_to_output' => false ), @@ -185,7 +185,7 @@ function ac_results_keyword_actions( $cakw_ID ) // Display results: $Results->display(); -if( $current_User->check_perm( 'centralantispam', 'edit' ) ) +if( check_user_perm( 'centralantispam', 'edit' ) ) { // Check permission to edit central antispam keyword: // Print JS to edit status of central antispam keyword: echo_editable_column_js( array( diff --git a/inc/central_antispam/views/_sources.form.php b/inc/central_antispam/views/_sources.form.php index b162938cbd7..664f3154e35 100644 --- a/inc/central_antispam/views/_sources.form.php +++ b/inc/central_antispam/views/_sources.form.php @@ -59,9 +59,7 @@ function get_link_for_keyword( $id, $keyword ) { - global $current_User; - - if( $current_User->check_perm( 'centralantispam', 'edit' ) ) + if( check_user_perm( 'centralantispam', 'edit' ) ) { // Not reserved id AND current User has permission to edit the global settings $ret_keyword = ''.$keyword.''; } diff --git a/inc/central_antispam/views/_sources.view.php b/inc/central_antispam/views/_sources.view.php index 51da884b4cd..926c81b3347 100644 --- a/inc/central_antispam/views/_sources.view.php +++ b/inc/central_antispam/views/_sources.view.php @@ -60,7 +60,7 @@ 'order' => 'casrc_status', 'th_class' => 'shrinkwrap', 'td_class' => 'jeditable_cell casource_status_edit', - 'td' => /* Check permission: */$current_User->check_perm( 'centralantispam', 'edit' ) ? + 'td' => /* Check permission: */check_user_perm( 'centralantispam', 'edit' ) ? /* Current user can edit source */'%ca_get_source_status_title( #casrc_status# )%' : /* No edit, only view the status */'%ca_get_keyword_status_title( #cakw_status# )%', 'extra' => array ( 'style' => 'background-color: %ca_get_source_status_color( "#casrc_status#" )%;color:#FFF', 'format_to_output' => false ), @@ -91,7 +91,7 @@ function ac_results_source_actions( $casrc_ID ) // Display results: $Results->display(); -if( $current_User->check_perm( 'centralantispam', 'edit' ) ) +if( check_user_perm( 'centralantispam', 'edit' ) ) { // Check permission to edit central antispam source: // Print JS to edit status of central antispam source: echo_editable_column_js( array( diff --git a/inc/chapters/chapters.ctrl.php b/inc/chapters/chapters.ctrl.php index bbdbca6d35d..0bd58d7f294 100644 --- a/inc/chapters/chapters.ctrl.php +++ b/inc/chapters/chapters.ctrl.php @@ -19,7 +19,7 @@ if( valid_blog_requested() ) { - $current_User->check_perm( 'blog_cats', 'edit', true, $blog ); + check_user_perm( 'blog_cats', 'edit', true, $blog ); $edited_Blog = & $Blog; } else @@ -34,7 +34,7 @@ // Restrict to chapters of the specific blog: $subset_ID = $blog; -$permission_to_edit = $current_User->check_perm( 'blog_cats', '', false, $blog ); +$permission_to_edit = check_user_perm( 'blog_cats', '', false, $blog ); // ---- Below is a modified generic category list editor: ----- @@ -297,7 +297,7 @@ function get_chapter_redirect_url( $redirect_page, $parent_ID, $chapter_ID = 0 ) // Control permission to edit source blog: $edited_Blog = & $edited_Chapter->get_Blog(); - if( ! $current_User->check_perm( 'blog_cats', '', false, $edited_Blog->ID ) ) + if( ! check_user_perm( 'blog_cats', '', false, $edited_Blog->ID ) ) { debug_die( 'No permission to edit source collection.' ); /* die */ @@ -305,7 +305,7 @@ function get_chapter_redirect_url( $redirect_page, $parent_ID, $chapter_ID = 0 ) // Control permission to edit destination blog: param( 'cat_coll_ID', 'integer', true ); - if( ! $current_User->check_perm( 'blog_cats', '', false, $cat_coll_ID ) ) + if( ! check_user_perm( 'blog_cats', '', false, $cat_coll_ID ) ) { // fp> TODO: prevent move in UI. $Messages->add( 'No permission to edit destination blog.', 'error' ); // NO TRANS b/c temporary @@ -504,8 +504,8 @@ function get_chapter_redirect_url( $redirect_page, $parent_ID, $chapter_ID = 0 ) } if( $action == 'list' ) -{ // Load JS to edit chapter order inline - require_js( 'jquery/jquery.jeditable.js', 'rsc_url' ); +{ // Load JS to edit chapter order inline + require_js_defer( 'customized:jquery/jeditable/jquery.jeditable.js', 'rsc_url' ); } if( in_array( $action, array( 'list', 'edit', 'move' ) ) ) diff --git a/inc/chapters/model/_chapter.class.php b/inc/chapters/model/_chapter.class.php index 49c94b6680c..fb40711bc50 100644 --- a/inc/chapters/model/_chapter.class.php +++ b/inc/chapters/model/_chapter.class.php @@ -829,10 +829,8 @@ function get_edit_url( $params = array() ) return false; } - global $current_User; - - if( ! $current_User->check_perm( 'admin', 'restricted' ) || - ! $current_User->check_perm( 'blog_cats', '', false, $this->blog_ID ) ) + if( ! check_user_perm( 'admin', 'restricted' ) || + ! check_user_perm( 'blog_cats', '', false, $this->blog_ID ) ) { // User has no right to edit this chapter return false; } diff --git a/inc/chapters/views/_chapter_list.view.php b/inc/chapters/views/_chapter_list.view.php index 488feb7218a..7f5bdc40549 100644 --- a/inc/chapters/views/_chapter_list.view.php +++ b/inc/chapters/views/_chapter_list.view.php @@ -51,7 +51,7 @@ */ function cat_line( $Chapter, $level ) { - global $line_class, $permission_to_edit, $current_User, $Settings, $admin_url; + global $line_class, $permission_to_edit, $Settings, $admin_url; global $ChapterCache, $current_default_cat_ID; global $number_of_posts_in_cat; diff --git a/inc/collections/_collections.init.php b/inc/collections/_collections.init.php index c4802f93207..4af324d859d 100644 --- a/inc/collections/_collections.init.php +++ b/inc/collections/_collections.init.php @@ -65,6 +65,7 @@ 'T_items__version_link' => $tableprefix.'items__version_link', 'T_items__votes' => $tableprefix.'items__votes', 'T_items__status_type' => $tableprefix.'items__status_type', + 'T_items__checklist_lines' => $tableprefix.'items__checklist_lines', 'T_links' => $tableprefix.'links', 'T_links__vote' => $tableprefix.'links__vote', 'T_postcats' => $tableprefix.'postcats', @@ -251,7 +252,7 @@ function & get_ItemStatusCache() if( ! isset( $ItemStatusCache ) ) { // Cache doesn't exist yet: load_class( 'items/model/_itemstatus.class.php', 'ItemStatus' ); - $ItemStatusCache = new DataObjectCache( 'ItemStatus', false, 'T_items__status', 'pst_', 'pst_ID', 'pst_name', 'pst_name', NT_('No status'), 0 ); + $ItemStatusCache = new DataObjectCache( 'ItemStatus', false, 'T_items__status', 'pst_', 'pst_ID', 'pst_name', 'pst_order', NT_('No status'), 0 ); } return $ItemStatusCache; @@ -294,6 +295,24 @@ function & get_ItemTagCache() return $ItemTagCache; } +/** + * Get the ChecklistLineCache + * + * @return ChecklistLineCache + */ +function & get_ChecklistLineCache() +{ + global $ChecklistLineCache; + + if( ! isset( $ChecklistLineCache ) ) + { // Cache doesn't exist yet: + load_class( 'items/model/_checklistline.class.php', 'ChecklistLine' ); + $ChecklistLineCache = new DataObjectCache( 'ChecklistLine', false, 'T_items__checklist_lines', 'check_', 'check_ID', 'check_label' ); + } + + return $ChecklistLineCache; +} + /** * Get the CommentCache * @@ -689,10 +708,6 @@ function check_getblog_group_perm( $permlevel, $permvalue, $permtarget ) function build_menu_1() { global $blog, $admin_url; - /** - * @var User - */ - global $current_User; global $Collection, $Blog; global $Settings; /** @@ -700,12 +715,12 @@ function build_menu_1() */ global $AdminUI; - if( ! $current_User->check_perm( 'admin', 'restricted' ) ) + if( ! check_user_perm( 'admin', 'restricted' ) ) { // don't show these menu entries if user hasn't at least admin restricted permission return; } - $perm_admin_normal = $current_User->check_perm( 'admin', 'normal' ); + $perm_admin_normal = check_user_perm( 'admin', 'normal' ); $site_menu = array( 'text' => T_('Site'), @@ -718,7 +733,7 @@ function build_menu_1() ); if( $perm_admin_normal ) { // User has an access to backoffice - if( $current_User->check_perm( 'options', 'view' ) ) + if( check_user_perm( 'options', 'view' ) ) { // User has an access to view settings $site_menu['entries']['settings'] = array( 'text' => T_('Site Settings'), @@ -754,14 +769,14 @@ function build_menu_1() ); } } - if( $current_User->check_perm( 'slugs', 'view' ) ) + if( check_user_perm( 'slugs', 'view' ) ) { // User has an access to view slugs $site_menu['entries']['slugs'] = array( 'text' => T_('Slugs'), 'href' => $admin_url.'?ctrl=slugs' ); } - if( $current_User->check_perm( 'options', 'view' ) ) + if( check_user_perm( 'options', 'view' ) ) { // User has an access to view settings $site_menu['entries']['tags'] = array( 'text' => T_('Tags'), @@ -791,10 +806,6 @@ function build_menu_1() function build_menu_2() { global $loc_transinfo, $ctrl, $admin_url; - /** - * @var User - */ - global $current_User; global $Collection, $Blog; /** * @var AdminUI_general @@ -815,8 +826,8 @@ function build_menu_2() 'order' => 'group_last' ), ); - $perm_comments = $current_User->check_perm( 'blog_comments', 'view', false, $blog ); - $perm_cats = $current_User->check_perm( 'blog_cats', '', false, $blog ); + $perm_comments = check_user_perm( 'blog_comments', 'view', false, $blog ); + $perm_cats = check_user_perm( 'blog_cats', '', false, $blog ); // Posts $collection_menu_entries['posts'] = array( @@ -825,7 +836,7 @@ function build_menu_2() ); $last_group_menu_entry = 'posts'; - if( $perm_comments || $current_User->check_perm( 'meta_comment', 'view', false, $blog ) ) + if( $perm_comments || check_user_perm( 'meta_comment', 'view', false, $blog ) ) { // Initialize comments menu tab if user can view normal or internal comments of the collection: $collection_menu_entries['comments'] = array( 'text' => T_('Comments'), @@ -850,7 +861,7 @@ function build_menu_2() $AdminUI->add_menu_entries( 'collections', $collection_menu_entries ); - if( $current_User->check_perm( 'blog_properties', 'edit', false, $blog ) ) + if( check_user_perm( 'blog_properties', 'edit', false, $blog ) ) { // Display these menus only when some blog is selected and current user has an access to edit the blog properties // BLOG SETTINGS: @@ -878,6 +889,9 @@ function build_menu_2() 'userdir' => array( 'text' => T_('User directory'), 'href' => $admin_url.'?ctrl=coll_settings&tab=userdir&blog='.$blog ), + 'search' => array( + 'text' => T_('Search'), + 'href' => $admin_url.'?ctrl=coll_settings&tab=search&blog='.$blog ), 'other' => array( 'text' => T_('Other displays'), 'href' => $admin_url.'?ctrl=coll_settings&tab=other&blog='.$blog ), @@ -956,7 +970,7 @@ function build_menu_2() ), ) ); - if( $current_User->check_perm( 'options', 'view' ) ) + if( check_user_perm( 'options', 'view' ) ) { // Manage skins $AdminUI->add_menu_entries( array( 'collections', 'skin' ), array( 'manage_skins' => array( @@ -965,7 +979,7 @@ function build_menu_2() ) ); } - if( $current_User->check_perm( 'options', 'view', false, $blog ) ) + if( check_user_perm( 'options', 'view', false, $blog ) ) { // Post Types & Statuses $AdminUI->add_menu_entries( array( 'collections', 'settings' ), array( 'types' => array( @@ -1000,7 +1014,7 @@ function build_menu_2() ) ); } - if( $current_User->check_perm( 'options', 'view' ) ) + if( check_user_perm( 'options', 'view' ) ) { // Check if current user has a permission to view the common settings of the blogs $AdminUI->add_menu_entries( array( 'collections', 'settings' ), array( 'blog_settings' => array( @@ -1022,22 +1036,18 @@ function build_menu_2() function build_menu_3() { global $blog, $loc_transinfo, $ctrl, $admin_url; - /** - * @var User - */ - global $current_User; global $Collection, $Blog; /** * @var AdminUI_general */ global $AdminUI; - if( !$current_User->check_perm( 'admin', 'normal' ) ) + if( ! check_user_perm( 'admin', 'normal' ) ) { return; } - if( $current_User->check_perm( 'options', 'view' ) ) + if( check_user_perm( 'options', 'view' ) ) { // Permission to view settings: $AdminUI->add_menu_entries( 'options', array( 'misc' => array( @@ -1167,7 +1177,7 @@ function handle_htsrv_action() // Check permission: $LinkOwner->check_perm( 'edit', true ); - if( $current_User->check_perm( 'files', 'edit' ) ) + if( check_user_perm( 'files', 'edit' ) ) { // If current User has permission to edit/delete files: // Get number of objects where this file is attached to: // TODO: attila>this must be handled with a different function @@ -1187,7 +1197,7 @@ function handle_htsrv_action() $Messages->add( $LinkOwner->translate( 'Link has been deleted from $xxx$.' ), 'success' ); - if( $current_User->check_perm( 'files', 'edit' ) ) + if( check_user_perm( 'files', 'edit' ) ) { // current User has permission to edit/delete files $file_name = $linked_File->get_name(); $links_count--; @@ -1644,7 +1654,7 @@ function handle_htsrv_action() $edited_Item = & $ItemCache->get_by_ID( $item_ID ); // Check perms: - $current_User->check_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item ); + check_user_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item ); if( empty( $item_tags ) && $edited_Item->get_type_setting( 'use_tags' ) == 'required' ) { // Tags must be entered: @@ -1668,10 +1678,107 @@ function handle_htsrv_action() { // Exit here when AJAX request, so we don't need a redirect after this function: exit(0); } + + case 'checklist_line': + global $DB; + + load_class('items/model/_checklistline.class.php', 'ChecklistLine' ); + + // Add/Update checklist line: + $item_action = param( 'item_action', 'string', 'add' ); + $item_ID = param( 'item_ID', 'integer', true ); + $checklist_ID = param( 'check_ID', 'integer', NULL ); + + $ItemCache = & get_ItemCache(); + $edited_Item = & $ItemCache->get_by_ID( $item_ID ); + + // Check perms: + check_user_perm( 'meta_comment', 'add', true, $edited_Item->get_blog_ID() ); + + if( $item_action == 'add' ) + { + $checklist_label = param( 'check_label', 'string', true ); + + if( empty( $checklist_ID ) ) + { + $checklistLine = new ChecklistLine(); + $checklistLine->set_Item( $edited_Item ); + $checklistLine->set( 'label', $checklist_label ); + $checklistLine->dbsave(); + $status = 'add'; + } + else + { + $ChecklistLineCache = & get_ChecklistLineCache(); + $checklistLine = & $ChecklistLineCache->get_by_ID( $checklist_ID ); + if( $checklist_label != $checklistLine->label ) + { + $checklistLine->set( 'label', $checklist_label ); + } + $checklistLine->dbsave(); + $status = 'update'; + } + + $response = array( + 'status' => $status, + 'check_ID' => $checklistLine->ID, + 'check_label' => $checklistLine->label, + ); + } + elseif( $item_action == 'toggle_check' ) + { + $checklist_checked = param( 'check_checked', 'boolean', NULL ); + + $ChecklistLineCache = & get_ChecklistLineCache(); + $checklistLine = & $ChecklistLineCache->get_by_ID( $checklist_ID ); + if( isset( $checklist_checked ) ) + { + $checklistLine->set( 'checked', $checklist_checked ? 1 : 0 ); + } + $checklistLine->dbsave(); + $status = 'toggle_check'; + + $response = array( + 'status' => $status, + 'check_ID' => $checklistLine->ID, + 'check_checked' => $checklistLine->checked, + ); + } + elseif( $item_action == 'delete' ) + { + $ChecklistLineCache = & get_ChecklistLineCache(); + $checklistLine = & $ChecklistLineCache->get_by_ID( $checklist_ID ); + + $response = array( + 'status' => 'delete', + 'check_ID' => $checklist_ID, + ); + + $checklistLine->dbdelete(); + } + elseif( $item_action == 'reorder' ) + { + $checklist_order = param( 'item_order', 'array', true ); + $update_query = 'UPDATE T_items__checklist_lines SET check_order = FIELD(check_ID, ' + .$DB->quote( $checklist_order ).') WHERE check_ID IN ('.$DB->quote( $checklist_order ).')'; + $DB->query( $update_query ); + + $response = array( + 'status' => 'reorder', + 'order' => $checklist_order, + ); + } + + // Do not append Debuglog and debug JSlog to JSON response in order to don't break it: + global $debug, $debug_jslog; + $debug = false; + $debug_jslog = false; + + exit( evo_json_encode( $response ) ); } } } $collections_Module = new collections_Module(); -?> \ No newline at end of file +?> diff --git a/inc/collections/_demo_content.funcs.php b/inc/collections/_demo_content.funcs.php index 4c81f378515..ef3faea1c06 100644 --- a/inc/collections/_demo_content.funcs.php +++ b/inc/collections/_demo_content.funcs.php @@ -40,7 +40,7 @@ */ function task_begin( $title ) { - echo get_install_format_text( $title."\n" ); + echo get_install_format_text_and_log( $title."\n" ); evo_flush(); } @@ -51,7 +51,7 @@ function task_begin( $title ) */ function task_end( $message = 'OK.' ) { - echo get_install_format_text( $message."
    \n", 'br' ); + echo get_install_format_text_and_log( $message."
    \n", 'br' ); } @@ -65,10 +65,10 @@ function task_errors( $errors = array(), $type = 'danger' ) return; } - echo get_install_format_text( '
    ', 'br' ); + echo get_install_format_text_and_log( '
    ', 'br' ); foreach( $errors as $error ) { - echo get_install_format_text( ''.$error.'
    ', 'br' ); + echo get_install_format_text_and_log( ''.$error.'
    ', 'br' ); } } @@ -1023,7 +1023,6 @@ function get_demo_users( $create = false, $output = true, &$error_messages = NUL function get_demo_user( $login, $create = false, $output = true, &$error_messages = NULL ) { global $DB; - global $current_User; global $user_timestamp; // Get list of demo users: @@ -1269,7 +1268,7 @@ function demo_content_error_handler( $errno, $errstr, $errfile, $errline ) { // handle only E_USER_NOTICE if( $errno == E_USER_NOTICE ) { - echo get_install_format_text( ''.$errstr.' ' ); + echo get_install_format_text_and_log( ''.$errstr.' ' ); } } @@ -1477,6 +1476,9 @@ function demo_content_error_handler( $errno, $errstr, $errfile, $errline ) // Use this var to shift the posts of the collections in time below: $timeshift = 0; + // Initialize for setup default widgets per collection: + $BlogCache = & get_BlogCache(); + if( $install_collection_home ) { // Install Home blog $coll_error_messages = array(); @@ -1491,12 +1493,9 @@ function demo_content_error_handler( $errno, $errstr, $errfile, $errline ) update_install_progress_bar(); } } - else + elseif( $Blog = & $BlogCache->get_by_ID( $blog_ID, false, false ) ) { // Insert basic widgets: - insert_basic_widgets( $blog_ID, 'normal', false, 'main' ); - insert_basic_widgets( $blog_ID, 'mobile', false, 'main' ); - insert_basic_widgets( $blog_ID, 'tablet', false, 'main' ); - insert_basic_widgets( $blog_ID, 'alt', false, 'main' ); + $Blog->setup_default_widgets(); } $collection_created++; @@ -1530,12 +1529,9 @@ function demo_content_error_handler( $errno, $errstr, $errfile, $errline ) update_install_progress_bar(); } } - else + elseif( $Blog = & $BlogCache->get_by_ID( $blog_ID, false, false ) ) { // Insert basic widgets: - insert_basic_widgets( $blog_ID, 'normal', false, 'std' ); - insert_basic_widgets( $blog_ID, 'mobile', false, 'std' ); - insert_basic_widgets( $blog_ID, 'tablet', false, 'std' ); - insert_basic_widgets( $blog_ID, 'alt', false, 'std' ); + $Blog->setup_default_widgets(); } $collection_created++; if( $coll_error_messages ) @@ -1568,12 +1564,9 @@ function demo_content_error_handler( $errno, $errstr, $errfile, $errline ) update_install_progress_bar(); } } - else + elseif( $Blog = & $BlogCache->get_by_ID( $blog_ID, false, false ) ) { // Insert basic widgets: - insert_basic_widgets( $blog_ID, 'normal', false, 'std' ); - insert_basic_widgets( $blog_ID, 'mobile', false, 'std' ); - insert_basic_widgets( $blog_ID, 'tablet', false, 'std' ); - insert_basic_widgets( $blog_ID, 'alt', false, 'std' ); + $Blog->setup_default_widgets(); } $collection_created++; if( $coll_error_messages ) @@ -1606,12 +1599,9 @@ function demo_content_error_handler( $errno, $errstr, $errfile, $errline ) update_install_progress_bar(); } } - else + elseif( $Blog = & $BlogCache->get_by_ID( $blog_ID, false, false ) ) { // Insert basic widgets: - insert_basic_widgets( $blog_ID, 'normal', false, 'photo' ); - insert_basic_widgets( $blog_ID, 'mobile', false, 'photo' ); - insert_basic_widgets( $blog_ID, 'tablet', false, 'photo' ); - insert_basic_widgets( $blog_ID, 'alt', false, 'photo' ); + $Blog->setup_default_widgets(); } $collection_created++; if( $coll_error_messages ) @@ -1644,12 +1634,9 @@ function demo_content_error_handler( $errno, $errstr, $errfile, $errline ) update_install_progress_bar(); } } - else + elseif( $Blog = & $BlogCache->get_by_ID( $blog_ID, false, false ) ) { // Insert basic widgets: - insert_basic_widgets( $blog_ID, 'normal', false, 'forum' ); - insert_basic_widgets( $blog_ID, 'mobile', false, 'forum' ); - insert_basic_widgets( $blog_ID, 'tablet', false, 'forum' ); - insert_basic_widgets( $blog_ID, 'alt', false, 'forum' ); + $Blog->setup_default_widgets(); } $collection_created++; if( $coll_error_messages ) @@ -1682,12 +1669,9 @@ function demo_content_error_handler( $errno, $errstr, $errfile, $errline ) update_install_progress_bar(); } } - else + elseif( $Blog = & $BlogCache->get_by_ID( $blog_ID, false, false ) ) { // Insert basic widgets: - insert_basic_widgets( $blog_ID, 'normal', false, 'manual' ); - insert_basic_widgets( $blog_ID, 'mobile', false, 'manual' ); - insert_basic_widgets( $blog_ID, 'tablet', false, 'manual' ); - insert_basic_widgets( $blog_ID, 'alt', false, 'manual' ); + $Blog->setup_default_widgets(); } $collection_created++; if( $coll_error_messages ) @@ -1720,12 +1704,9 @@ function demo_content_error_handler( $errno, $errstr, $errfile, $errline ) update_install_progress_bar(); } } - else + elseif( $Blog = & $BlogCache->get_by_ID( $blog_ID, false, false ) ) { // Insert basic widgets: - insert_basic_widgets( $blog_ID, 'normal', false, 'group' ); - insert_basic_widgets( $blog_ID, 'mobile', false, 'group' ); - insert_basic_widgets( $blog_ID, 'tablet', false, 'group' ); - insert_basic_widgets( $blog_ID, 'alt', false, 'group' ); + $Blog->setup_default_widgets(); } $collection_created++; if( $coll_error_messages ) @@ -1757,13 +1738,9 @@ function demo_content_error_handler( $errno, $errstr, $errfile, $errline ) update_install_progress_bar(); } } - else - { - // Insert basic widgets: - insert_basic_widgets( $blog_ID, 'normal', false, 'minisite' ); - insert_basic_widgets( $blog_ID, 'mobile', false, 'minisite' ); - insert_basic_widgets( $blog_ID, 'tablet', false, 'minisite' ); - insert_basic_widgets( $blog_ID, 'alt', false, 'minisite' ); + elseif( $Blog = & $BlogCache->get_by_ID( $blog_ID, false, false ) ) + { // Insert basic widgets: + $Blog->setup_default_widgets(); } $collection_created++; if( $coll_error_messages ) @@ -1784,7 +1761,7 @@ function demo_content_error_handler( $errno, $errstr, $errfile, $errline ) // Install default shared widgets: global $installed_default_shared_widgets; task_begin( TB_('Installing default shared widgets...') ); - insert_shared_widgets( 'normal', true ); + insert_shared_widgets( 'normal' ); task_end(); $installed_default_shared_widgets = true; @@ -2659,21 +2636,21 @@ function create_sample_content( $collection_type, $blog_ID, $owner_ID, $use_demo 'category' => 'background', 'type' => 'Child Post', 'parent_ID' => '#get_item#another_custom_fields_example#ID#', - 'content' => '

    '.sprintf( TD_('This post has a special post type called "Child Post". This allowed to specify a parent post ID. Consequently, this child post is linked to: %s.'), '[parent:titlelink] ([parent:url])' ).'

    -

    '.TD_('This also allows us to access the custom fields of the parent post:').'

    -

    [parent:fields]

    -[teaserbreak] -

    '.TD_('It is also possible to selectively display only a couple of these fields:').'

    -

    [parent:fields:first_numeric_field,first_string_field,second_numeric_field]

    -

    '.sprintf( TD_('Finally, we can also display just the value of a specific field, like this: %s.'), '[parent:field:first_string_field]' ).'

    -

    '.sprintf( TD_('We can also reference fields of any other post like this: %s or like this: %s.'), '[item:another-custom-fields-example:field:first_string_field]', '[item:#get_item#another_custom_fields_example#ID#:field:first_string_field]' ).'

    -

    '.sprintf( TD_('It is also possible to create links using a custom field URL from the parent post: %s'), '[parent:link:url_field:.btn.btn-info]Click me![/link]' ).'

    -

    '.TD_('Replicated fields').'

    -

    '.TD_('By using the same field names, it is also possible to automatically replicate some fields from parent to child (recursively).').'

    -

    '.TD_('This child post has the following fields which automatically replicate from its parent:').'

    -

    [fields]

    -

    '.sprintf( TD_('Another way to show this, is to use b2evolution\'s %s short tag:'), '`[compare:...]`' ).'

    -

    [compare:$this$,$parent$]

    ', + 'content' => sprintf( TD_('This post has a special post type called "Child Post". This allowed to specify a parent post ID. Consequently, this child post is linked to: %s.'), '[parent:titlelink] ([parent:url])' )."\n\n" +.TD_('This also allows us to access the custom fields of the parent post:')."\n\n" +.'[parent:fields]'."\n\n" +.'[teaserbreak]'."\n\n" +.TD_('It is also possible to selectively display only a couple of these fields:')."\n\n" +.'[parent:fields:first_numeric_field,first_string_field,second_numeric_field]'."\n\n" +.sprintf( TD_('Finally, we can also display just the value of a specific field, like this: %s.'), '[parent:field:first_string_field]' )."\n\n" +.sprintf( TD_('We can also reference fields of any other post like this: %s or like this: %s.'), '[item:another-custom-fields-example:field:first_string_field]', '[item:#get_item#another_custom_fields_example#ID#:field:first_string_field]' )."\n\n" +.sprintf( TD_('It is also possible to create links using a custom field URL from the parent post: %s'), '[parent:link:url_field:.btn.btn-info]Click me![/link]' )."\n\n" +.'###'.TD_('Replicated fields')."\n\n" +.TD_('By using the same field names, it is also possible to automatically replicate some fields from parent to child (recursively).')."\n\n" +.TD_('This child post has the following fields which automatically replicate from its parent:')."\n\n" +.'[fields]'."\n\n" +.sprintf( TD_('Another way to show this, is to use b2evolution\'s %s short tag:'), '`[compare:...]`' )."\n\n" +.'[compare:$this$,$parent$]', 'custom_fields' => array( array( 'first_numeric_field', '123' ), array( 'first_string_field', 'abc' ), @@ -2683,6 +2660,9 @@ function create_sample_content( $collection_type, $blog_ID, $owner_ID, $use_demo 'files' => array( array( 'monument-valley/monument-valley-road.jpg', 'attachment', 'custom_field' => 'image_1' ), ), + 'settings' => array( + 'editor_code' => 'html', // use markup(don't use tinymce) edtior by default for this demo item + ), ); $demo_items['extended_post_with_no_teaser'] = array( @@ -3618,7 +3598,6 @@ function create_sample_content( $collection_type, $blog_ID, $owner_ID, $use_demo $categories = array( 'bug' => array( TD_('Bug'), 'order' => 10 ), 'feature_request' => array( TD_('Feature Request'), 'order' => 20 ), - 'recipes' => array( TD_('Recipes'), 'default_item_type' => 'Recipe' ), ); // Additional sample Items: @@ -3690,6 +3669,15 @@ function create_sample_content( $collection_type, $blog_ID, $owner_ID, $use_demo // Prepend additional sample Items before generic Items: $demo_items = array_merge( $top_demo_items, $demo_items ); + + // Don't install the following demo Items: + $exclude_demo_items = array( + 'mongolian_beef', + 'stuffed_peppers', + 'custom_fields_example', + 'another_custom_fields_example', + 'child_post_example', + ); break; } @@ -3707,7 +3695,7 @@ function create_sample_content( $collection_type, $blog_ID, $owner_ID, $use_demo $edited_Blog->dbupdate(); } - if( isset( $exclude_demo_items ) ) + if( ! empty( $exclude_demo_items ) ) { // Exclude demo items which must not be installed: foreach( $exclude_demo_items as $exclude_demo_item_key ) { @@ -4176,7 +4164,7 @@ function install_demo_content() $DB->begin(); if( $create_demo_organization ) { - echo get_install_format_text( '

    '.TB_('Creating demo organization and users...').'

    ', 'h2' ); + echo get_install_format_text_and_log( '

    '.TB_('Creating demo organization and users...').'

    ', 'h2' ); evo_flush(); if( $create_demo_organization ) @@ -4221,7 +4209,7 @@ function install_demo_content() $emails_data_installed = 0; if( $create_sample_contents || $create_demo_email_lists ) { - echo get_install_format_text( '

    '.TB_('Creating demo website...').'

    ', 'h2' ); + echo get_install_format_text_and_log( '

    '.TB_('Creating demo website...').'

    ', 'h2' ); } if( $create_sample_contents ) @@ -4239,7 +4227,7 @@ function install_demo_content() { evo_flush(); echo '
    '; - echo get_install_format_text( ''.TB_('Demo elements successfully created.').'' ); + echo get_install_format_text_and_log( ''.TB_('Demo elements successfully created.').'' ); if( $collections_installed ) { // Display button to view website if at least one collection was created: diff --git a/inc/collections/_search.funcs.php b/inc/collections/_search.funcs.php index 968ec75d515..13f26a79cee 100644 --- a/inc/collections/_search.funcs.php +++ b/inc/collections/_search.funcs.php @@ -187,6 +187,7 @@ function score_date( $date, $score_weights = array() ) /** * Count score of multiple occurrences + * * The score is sum( $score_weight / x ) where x goes from 2 to match count * * @param integer match count @@ -238,7 +239,7 @@ function get_percentage_from_result_map( $type, $scores_map, $quoted_parts, $key debug_die( 'Invalid search type received!' ); } - // Check whole term match + // Check whole term match: foreach( $searched_parts as $searched_part ) { if( isset( $scores_map[$searched_part]['map']['whole_term'] ) ) @@ -247,7 +248,7 @@ function get_percentage_from_result_map( $type, $scores_map, $quoted_parts, $key } } - // Whole search term was not found, count percentage based on the matched parts + // Whole search term was not found, count percentage based on the matched parts: $matched_quoted_parts = 0; foreach( $quoted_parts as $quoted_part ) { @@ -383,7 +384,7 @@ function search_and_score_items( $search_term, $keywords, $quoted_parts, $exclud $search_ItemList->query_init(); if( ! is_logged_in() && ! empty( $authors ) ) - { // This is necessary because the 'authors_login' filter above will not work for non-existent logins and + { // This is necessary because the 'authors_login' filter above will not work for non-existent logins $search_ItemList->ItemQuery->WHERE_and( 'user_login = '.$DB->quote( $authors ) ); } @@ -684,29 +685,36 @@ function search_and_score_files( $search_term, $keywords, $quoted_parts, $author $files_SQL->FROM_add( 'LEFT JOIN T_comments ON link_cmt_ID = comment_ID' ); $files_SQL->FROM_add( 'LEFT JOIN T_postcats AS cpc ON comment_item_ID = cpc.postcat_post_ID' ); $files_SQL->FROM_add( 'LEFT JOIN T_categories AS ccat ON cpc.postcat_cat_ID = ccat.cat_ID' ); + if( ! empty( $authors ) && ! is_logged_in() ) { $files_SQL->FROM_add( 'LEFT JOIN T_users AS iuser ON comment_author_user_ID = iuser.user_ID' ); $files_SQL->FROM_add( 'LEFT JOIN T_users AS cuser ON comment_author_user_ID = cuser.user_ID' ); } + $files_SQL->WHERE( '( icat.cat_blog_ID = '.$DB->quote( $Blog->ID ).' OR ccat.cat_blog_ID = '.$DB->quote( $Blog->ID ).' )' ); $files_SQL->WHERE_and( $file_where_condition ); + if( ! empty( $authors ) ) { if( is_logged_in() ) { - if( preg_match( '/^[0-9]+(,[0-9]+)*$/', $authors ) === false ) - { - debug_die( 'Invalid comment author filter request' ); + if( preg_match( '/^[0-9]+(,[0-9]+)*$/', $authors ) ) + { // If JS active, we will receive a numeric list: + $files_SQL->WHERE_and( '( comment_author_user_ID IN ('.$authors.') OR post_creator_user_ID IN ('.$authors.') )' ); + } + else + { // If JS not active, we will have more limited results. + // TODO: Extend support for search without JS + $files_SQL->WHERE_and( '( comment_author = '.$DB->quote( $authors ).' )' ); } - - $files_SQL->WHERE_and( '( comment_author_user_ID IN ('.$authors.') OR post_creator_user_ID IN ('.$authors.') )' ); } else { $files_SQL->WHERE_and( '( comment_author = '.$DB->quote( $authors ).' OR cuser.user_login = '.$DB->quote( $authors ).' OR iuser.user_login = '.$DB->quote( $authors ).' )' ); } } + if( $content_age != '' ) { $date_min = remove_seconds( strtotime( get_search_date_by_content_age( $content_age ) ) + $time_difference ); @@ -779,7 +787,7 @@ function perform_scored_search( $search_keywords, $searched_content_types = 'all return array(); } - global $Collection, $Blog, $DB, $debug, $current_User; + global $Collection, $Blog, $DB, $debug; global $scores_map, $score_prefix, $score_map_key, $Debuglog; // Get quoted parts parts of the search query @@ -874,8 +882,7 @@ function perform_scored_search( $search_keywords, $searched_content_types = 'all if( $search_type_meta && $Blog->get_setting( 'search_include_metas' ) && - is_logged_in() && - $current_User->check_perm( 'meta_comment', 'view', false, $Blog->ID ) ) + check_user_perm( 'meta_comment', 'view', false, $Blog->ID ) ) { // Perform search on Meta/Internal Comments: $meta_search_result = search_and_score_comments( $search_keywords, $keywords, $quoted_parts, $search_authors, $content_age, 'meta' ); $search_result = array_merge( $search_result, $meta_search_result ); @@ -994,13 +1001,14 @@ function perform_scored_search( $search_keywords, $searched_content_types = 'all /* * Perform search (after having displayed the first part of the page) & display results. + * * The search results are cached in the session for faster page by page navigation. * * @param array Display Params */ function search_result_block( $params = array() ) { - global $Collection, $Blog, $Session, $debug, $current_User; + global $Collection, $Blog, $Session, $debug; $search_keywords = param( 's', 'string', '', true ); $search_authors = param( 'search_author', 'string', '' ); @@ -1023,6 +1031,9 @@ function search_result_block( $params = array() ) echo '

    Starting a new search...

    '; } + // Display search spinner: + echo '
    '; + // Flush first part of the page before starting search, which can be long... evo_flush(); @@ -1041,8 +1052,7 @@ function search_result_block( $params = array() ) $searched_content_types[] = 'comment'; } if( $Blog->get_setting( 'search_include_metas' ) && - is_logged_in() && - $current_User->check_perm( 'meta_comment', 'view', false, $Blog->ID ) ) + check_user_perm( 'meta_comment', 'view', false, $Blog->ID ) ) { // Search meta/internal comments: $searched_content_types[] = 'meta'; } @@ -1128,6 +1138,7 @@ function search_result_block( $params = array() ) if( empty( $search_result ) ) { echo $params['no_match_message']; + hide_spinner(); return; } @@ -1362,6 +1373,8 @@ function search_result_block( $params = array() ) { search_page_links( $page_params ); } + + hide_spinner(); } @@ -1902,3 +1915,23 @@ function display_search_debug_info( $search_result ) $Debuglog->add( sprintf('Result for [%s]: [Percentage:%d%%][Percentage score:%d][Total score:%d]', $score_map_key, $search_result[$index]['percentage'], $search_result[$index]['percentage_score'], $search_result[$index]['score']), 'info' ); } } + + +/** + * Hide spinner + */ +function hide_spinner() +{ + ?> + + assert_received_crumb( 'collection' ); // Check permissions: - $current_User->check_perm( 'blog_properties', 'edit', true, $blog ); + check_user_perm( 'blog_properties', 'edit', true, $blog ); // Set URL to redirect after succesful action: $update_redirect_url = '?ctrl=coll_settings&tab='.$tab.'&blog='.$blog.( empty( $mode ) ? '' : '&mode='.$mode ); @@ -149,6 +149,7 @@ case 'features': case 'contact': case 'userdir': + case 'search': case 'other': case 'popup': case 'metadata': @@ -178,8 +179,27 @@ if( $edited_Blog->load_from_Request( array() ) ) { // Commit update to the DB: $edited_Blog->dbupdate(); - // Re-scan and create widget containers from new switched skin if they don't exist for the edited collection: - $edited_Blog->db_save_main_containers(); + + if( param( 'reset_widgets', 'integer', 0 ) ) + { // Widget must be reseted: + $updated_skin_type = ''; + if( get_param( 'normal_skin_ID' ) !== NULL ) + { // Normal skin has been changed: + $updated_skin_type = 'normal'; + } + elseif( get_param( 'tablet_skin_ID' ) !== NULL ) + { // Tablet skin has been changed: + $updated_skin_type = 'tablet'; + } + elseif( get_param( 'mobile_skin_ID' ) !== NULL ) + { // Mobile skin has been changed: + $updated_skin_type = 'mobile'; + } + if( ! empty( $updated_skin_type ) ) + { // Reset previous widgets with new from skin default widget declarations: + $edited_Blog->reset_widgets( $updated_skin_type ); + } + } $Messages->add( TB_('The blog skin has been changed.') .' '.TB_('Edit...').'', 'success' ); @@ -285,7 +305,7 @@ case 'advanced': if( $edited_Blog->load_from_Request( array( 'pings', 'cache', 'authors', 'login', 'styles', 'template', 'credits', 'meta' ) ) ) { // Commit update to the DB: - if( $current_User->check_perm( 'blog_admin', 'edit', false, $edited_Blog->ID ) ) + if( check_user_perm( 'blog_admin', 'edit', false, $edited_Blog->ID ) ) { $cache_status = param( 'cache_enabled', 'integer', 0 ); load_funcs( 'collections/model/_blog.funcs.php' ); @@ -332,7 +352,7 @@ $Session->assert_received_crumb( 'collection' ); // Check permissions: - $current_User->check_perm( 'blog_properties', 'edit', true, $blog ); + check_user_perm( 'blog_properties', 'edit', true, $blog ); $update_redirect_url = '?ctrl=coll_settings&tab='.$tab.'&blog='.$blog; param( 'reset', 'boolean', '' ); @@ -346,22 +366,13 @@ } if( $reset ) - { // Reset all settings - // Remove previous widgets, widget containers, plugin and skin settings - $DB->query( 'DELETE wico, wi - FROM T_widget__container AS wico - LEFT JOIN T_widget__widget AS wi ON wi_wico_ID = wico_ID - WHERE wico_coll_ID = '.$DB->quote( $edited_Blog->ID ) ); - + { // Reset all settings: + // Remove previous plugin and skin settings: $DB->query( 'DELETE FROM T_coll_settings WHERE cset_coll_ID = '.$DB->quote( $edited_Blog->ID ).' AND ( cset_name LIKE "skin%" OR cset_name LIKE "plugin%" )' ); - // ADD DEFAULT WIDGETS: - load_funcs( 'widgets/_widgets.funcs.php' ); - insert_basic_widgets( $edited_Blog->ID, 'normal', false, $type ); - insert_basic_widgets( $edited_Blog->ID, 'mobile', false, $type ); - insert_basic_widgets( $edited_Blog->ID, 'tablet', false, $type ); - insert_basic_widgets( $edited_Blog->ID, 'alt', false, $type ); + // Reset previous widgets with new from all skins default widget declarations: + $edited_Blog->reset_widgets(); } $edited_Blog->init_by_kind( $type, $edited_Blog->get( 'name' ), $edited_Blog->get( 'shortname' ), $edited_Blog->get( 'urlname' ) ); @@ -381,7 +392,7 @@ $Session->assert_received_crumb( 'collection' ); // Check permissions: - $current_User->check_perm( 'blog_properties', 'edit', true, $blog ); + check_user_perm( 'blog_properties', 'edit', true, $blog ); $update_redirect_url = $admin_url.'?ctrl=collections'; @@ -475,7 +486,7 @@ // load dashboard functions load_funcs( 'dashboard/model/_dashboard.funcs.php' ); - if( ! $current_User->check_perm( 'blog_ismember', 'view', false, $blog ) ) + if( ! check_user_perm( 'blog_ismember', 'view', false, $blog ) ) { // We don't have permission for the requested blog (may happen if we come to admin from a link on a different blog) set_working_blog( 0 ); unset( $Blog, $Collection ); @@ -496,7 +507,7 @@ $activate_collection_toolbar = true; // Load jquery UI to animate background color on change comment status and to transfer a comment to recycle bin - require_js( '#jqueryUI#' ); + require_js_defer( '#jqueryUI#' ); // Load the appropriate blog navigation styles (including calendar, comment forms...): require_css( $AdminUI->get_template( 'blog_base.css' ) ); // Default styles for the blog navigation @@ -504,8 +515,8 @@ require_js_helper( 'colorbox' ); // Include files to work with charts - require_js( '#easypiechart#' ); - require_css( 'jquery/jquery.easy-pie-chart.css' ); + require_js_defer( '#easypiechart#' ); + require_css( 'ext:jquery/easy-pie-chart/css/jquery.easy-pie-chart.css' ); // Display ... section! (Note: should be done early if actions do not redirect) $AdminUI->disp_html_head(); @@ -529,7 +540,7 @@ foreach( $blog_moderation_statuses as $status ) { - if( ( $status !== $highest_publish_status ) && $current_User->check_perm( 'blog_comment!'.$status, 'edit', false, $blog ) ) + if( ( $status !== $highest_publish_status ) && check_user_perm( 'blog_comment!'.$status, 'edit', false, $blog ) ) { $user_modeartion_statuses[] = $status; } @@ -611,7 +622,7 @@ echo '
    '; // Block Group 1 - $perm_options_edit = $current_User->check_perm( 'options', 'edit' ); + $perm_options_edit = check_user_perm( 'options', 'edit' ); if( $perm_options_edit ) { @@ -620,7 +631,7 @@ echo '
    '; $side_item_Widget = new Widget( 'side_item' ); - $perm_blog_properties = $current_User->check_perm( 'blog_properties', 'edit', false, $Blog->ID ); + $perm_blog_properties = check_user_perm( 'blog_properties', 'edit', false, $Blog->ID ); // Collection Analytics Block if( $perm_options_edit ) @@ -666,7 +677,7 @@ if( $Blog->get( 'notes' ) ) { $edit_link = ''; - if( $current_User->check_perm( 'blog_properties', 'edit', false, $blog ) ) + if( check_user_perm( 'blog_properties', 'edit', false, $blog ) ) { $edit_link = action_icon( TB_('Edit').'...', 'edit_button', $admin_url.'?ctrl=coll_settings&tab=general&blog='.$Blog->ID, ' '.TB_('Edit').'...', 3, 4, array( 'class' => 'btn btn-default btn-sm' ) ); } @@ -762,7 +773,7 @@ .( $have_comments_to_moderate || $have_posts_to_moderate ? ' col-md-pull-0 col-lg-6 col-lg-pull-0' : '' ).'">'; } - if( $current_User->check_perm( 'meta_comment', 'view', false, $Blog->ID ) ) + if( check_user_perm( 'meta_comment', 'view', false, $Blog->ID ) ) { // If user has a perm to view internal comments of the collection: // Latest Internal Comments Block @@ -844,7 +855,7 @@ $nb_blocks_displayed++; echo ''; - if( $current_User->check_perm( 'blog_post_statuses', 'edit', false, $Blog->ID ) ) + if( check_user_perm( 'blog_post_statuses', 'edit', false, $Blog->ID ) ) { // We have permission to add a post with at least one status: $block_item_Widget->global_icon( TB_('Write a new post...'), 'new', '?ctrl=items&action=new&blog='.$Blog->ID, TB_('New post').' »', 3, 4, array( 'class' => 'action_icon btn-primary btn-sm' ) ); } @@ -889,8 +900,8 @@ 'after' => '
    ', 'image_size' => 'crop-80x80', 'limit' => 1, - // Optionally restrict to files/images linked to specific position: 'teaser'|'teaserperm'|'teaserlink'|'aftermore'|'inline'|'fallback'|'cover' - 'restrict_to_image_position' => 'cover,teaser,teaserperm,teaserlink,aftermore,inline', + // Optionally restrict to files/images linked to specific position: 'teaser'|'teaserperm'|'teaserlink'|'aftermore'|'inline'|'fallback'|'cover'|'background' + 'restrict_to_image_position' => 'cover,background,teaser,teaserperm,teaserlink,aftermore,inline', // Sort the attachments to get firstly "Cover", then "Teaser", and "After more" as last order 'links_sql_select' => ', CASE ' .'WHEN link_position = "cover" THEN "1" ' @@ -1090,6 +1101,13 @@ function get_color_hex( start_color, end_color ) $AdminUI->set_page_manual_link( 'features-user-directory' ); break; + case 'search': + $AdminUI->set_path( 'collections', 'features', $tab ); + $AdminUI->breadcrumbpath_add( TB_('Features'), '?ctrl=coll_settings&blog=$blog$&tab=home' ); + $AdminUI->breadcrumbpath_add( TB_('Search'), '?ctrl=coll_settings&blog=$blog$&tab='.$tab ); + $AdminUI->set_page_manual_link( 'features-search' ); + break; + case 'other': $AdminUI->set_path( 'collections', 'features', $tab ); $AdminUI->breadcrumbpath_add( TB_('Features'), '?ctrl=coll_settings&blog=$blog$&tab=home' ); @@ -1170,7 +1188,7 @@ function get_color_hex( start_color, end_color ) $AdminUI->breadcrumbpath_add( TB_('User permissions'), '?ctrl=coll_settings&blog=$blog$&tab='.$tab ); $AdminUI->set_page_manual_link( 'advanced-user-permissions' ); // Load JavaScript to toggle checkboxes: - require_js( 'collectionperms.js', 'rsc_url' ); + require_js_async( 'collectionperms.js', 'rsc_url' ); break; case 'permgroup': @@ -1180,7 +1198,7 @@ function get_color_hex( start_color, end_color ) $AdminUI->breadcrumbpath_add( TB_('Group permissions'), '?ctrl=coll_settings&blog=$blog$&tab='.$tab ); $AdminUI->set_page_manual_link( 'advanced-group-permissions' ); // Load JavaScript to toggle checkboxes: - require_js( 'collectionperms.js', 'rsc_url' ); + require_js_async( 'collectionperms.js', 'rsc_url' ); break; } @@ -1217,6 +1235,9 @@ function get_color_hex( start_color, end_color ) case 'userdir': $AdminUI->disp_view( 'collections/views/_coll_user_dir.form.php' ); break; + case 'search': + $AdminUI->disp_view( 'collections/views/_coll_search.form.php' ); + break; case 'other': $AdminUI->disp_view( 'collections/views/_coll_other.form.php' ); break; diff --git a/inc/collections/collections.ctrl.php b/inc/collections/collections.ctrl.php index 994659a3ede..7528a049a04 100644 --- a/inc/collections/collections.ctrl.php +++ b/inc/collections/collections.ctrl.php @@ -86,7 +86,7 @@ } // Check permissions to create new collection: - if( ! $current_User->check_perm( 'blogs', 'create', false, $sec_ID ) ) + if( ! check_user_perm( 'blogs', 'create', false, $sec_ID ) ) { $Messages->add( TB_('You don\'t have permission to create a collection.'), 'error' ); $redirect_to = param( 'redirect_to', 'url', $admin_url ); @@ -94,7 +94,7 @@ } // Check permissions to copy the selected collection: - if( $action == 'copy' && ! $current_User->check_perm( 'blog_properties', 'copy', false, $edited_Blog->ID ) ) + if( $action == 'copy' && ! check_user_perm( 'blog_properties', 'copy', false, $edited_Blog->ID ) ) { $Messages->add( sprintf( TB_('You don\'t have a permission to copy the collection "%s".'), $edited_Blog->get( 'shortname' ) ), 'error' ); $redirect_to = param( 'redirect_to', 'url', $admin_url ); @@ -127,7 +127,7 @@ param( 'sec_ID', 'integer', 0, true ); // Check permissions: - $current_User->check_perm( 'blogs', 'create', true, $sec_ID ); + check_user_perm( 'blogs', 'create', true, $sec_ID ); param( 'kind', 'string', true ); @@ -140,7 +140,7 @@ param( 'sec_ID', 'integer', 0 ); // Check permissions: - $current_User->check_perm( 'blogs', 'create', true, $sec_ID ); + check_user_perm( 'blogs', 'create', true, $sec_ID ); $edited_Blog = new Blog( NULL ); @@ -169,7 +169,7 @@ param( 'sec_ID', 'integer', 0 ); // Check permissions: - $current_User->check_perm( 'blogs', 'create', true, $sec_ID ); + check_user_perm( 'blogs', 'create', true, $sec_ID ); $edited_Blog = new Blog( NULL ); @@ -178,7 +178,7 @@ param( 'kind', 'string', true ); param( 'blog_urlname', 'string', true ); - if( $kind == 'main' && ! $current_User->check_perm( 'blog_admin', 'editAll', false ) ) + if( $kind == 'main' && ! check_user_perm( 'blog_admin', 'editAll', false ) ) { // Non-collection admins should not be able to create home/main collections $Messages->add( sprintf( TB_('You don\'t have permission to create a collection of kind %s.'), '«'.$kind.'»' ), 'error' ); header_redirect( $admin_url.'?ctrl=collections' ); // will EXIT @@ -189,7 +189,7 @@ $edited_Blog->set( 'normal_skin_ID', $skin_ID ); $edited_Blog->init_by_kind( $kind ); - if( ! $current_User->check_perm( 'blog_admin', 'edit', false, $edited_Blog->ID ) ) + if( ! check_user_perm( 'blog_admin', 'edit', false, $edited_Blog->ID ) ) { // validate the urlname, which was already set by init_by_kind() function // It needs to validated, because the user can not set the blog urlname, and every new blog would have the same urlname without validation. // When user has edit permission to blog admin part, the urlname will be validated in load_from_request() function. @@ -259,7 +259,7 @@ param( 'sec_ID', 'integer', 0 ); // Check permissions: - $current_User->check_perm( 'blog_properties', 'copy', true, $edited_Blog->ID ); + check_user_perm( 'blog_properties', 'copy', true, $edited_Blog->ID ); // Get name of the duplicating collection to display on the form: $duplicating_collection_name = $edited_Blog->get( 'shortname' ); @@ -287,7 +287,7 @@ $Session->assert_received_crumb( 'collection' ); // Check permissions: - $current_User->check_perm( 'blog_properties', 'edit', true, $blog ); + check_user_perm( 'blog_properties', 'edit', true, $blog ); if( param( 'confirm', 'integer', 0 ) ) { // confirmed @@ -330,7 +330,7 @@ $Session->assert_received_crumb( 'collectionsettings' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); $Settings->set( 'blogs_order_by', param( 'blogs_order_by', 'string', true ) ); $Settings->set( 'blogs_order_dir', param( 'blogs_order_dir', 'string', true ) ); @@ -403,10 +403,10 @@ $Session->assert_received_crumb( 'collectionsettings' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Lock system - if( $current_User->check_perm( 'users', 'edit' ) ) + if( check_user_perm( 'users', 'edit' ) ) { $system_lock = param( 'system_lock', 'integer', 0 ); if( $Settings->get( 'system_lock' ) && ( ! $system_lock ) && ( ! $Messages->has_errors() ) && ( 1 == $Messages->count() ) ) @@ -502,7 +502,7 @@ // New/Edit section: // Check permissions: - $current_User->check_perm( 'section', 'view', true, $edited_Section->ID ); + check_user_perm( 'section', 'view', true, $edited_Section->ID ); break; case 'create_section': @@ -513,7 +513,7 @@ $Session->assert_received_crumb( 'section' ); // Check permission: - $current_User->check_perm( 'section', 'edit', true, $edited_Section->ID ); + check_user_perm( 'section', 'edit', true, $edited_Section->ID ); if( $edited_Section->load_from_Request() ) { @@ -542,7 +542,7 @@ $Session->assert_received_crumb( 'section' ); // Check permissions: - $current_User->check_perm( 'section', 'edit', true, $edited_Section->ID ); + check_user_perm( 'section', 'edit', true, $edited_Section->ID ); if( $edited_Section->ID == 1 ) { // Forbid to delete default section: @@ -577,7 +577,7 @@ $Session->assert_received_crumb( 'siteskin' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); param( 'skinpage', 'string', '' ); @@ -692,7 +692,7 @@ $Session->assert_received_crumb( 'demo_content' ); // Check permission: - $current_User->check_perm( 'blogs', 'create', true ); + check_user_perm( 'blogs', 'create', true ); // Install process is executed below in template in order to display it in real time. break; @@ -704,7 +704,7 @@ if( $Settings->get( 'site_skins_enabled' ) ) { // Check minimum permission: - $current_User->check_perm( 'options', 'view', true ); + check_user_perm( 'options', 'view', true ); $AdminUI->set_path( 'site', 'skin', 'skin_'.$skin_type ); @@ -726,7 +726,7 @@ case 'site_settings': // Check minimum permission: - $current_User->check_perm( 'options', 'view', true ); + check_user_perm( 'options', 'view', true ); $AdminUI->set_path( 'site', 'settings' ); @@ -741,7 +741,7 @@ case 'blog_settings': // Check minimum permission: - $current_User->check_perm( 'options', 'view', true ); + check_user_perm( 'options', 'view', true ); // We should activate toolbar menu items for this controller and tab $activate_collection_toolbar = true; @@ -1010,7 +1010,7 @@ } // Welcome panel to create demo content: - if( $current_User->check_perm( 'blogs', 'create' ) && $collection_count == 0 ) + if( check_user_perm( 'blogs', 'create' ) && $collection_count == 0 ) { $AdminUI->disp_view( 'collections/views/_welcome_demo_content.view.php' ); } diff --git a/inc/collections/model/_blog.class.php b/inc/collections/model/_blog.class.php index 7e537989e29..dcee99b9f39 100644 --- a/inc/collections/model/_blog.class.php +++ b/inc/collections/model/_blog.class.php @@ -441,12 +441,14 @@ function init_by_kind( $kind, $name = NULL, $shortname = NULL, $urlname = NULL ) $this->set( 'shortname', empty($shortname) ? T_('Tracker') : $shortname ); $this->set( 'urlname', empty($urlname) ? 'tracker' : $urlname ); $this->set_setting( 'use_workflow', 1 ); + $this->set_setting( 'in_skin_editing', '1' ); $this->set_setting( 'front_disp', 'front' ); + $this->set_setting( 'download_enable', 0 ); // Try to find post type "Forum Topic" in DB global $DB; $forum_topic_type_ID = $DB->get_var( 'SELECT ityp_ID FROM T_items__type - WHERE ityp_name = "Forum Topic"' ); + WHERE ityp_name = "Task"' ); if( $forum_topic_type_ID ) { // Set default post type as "Forum Topic" $this->set_setting( 'default_post_type', $forum_topic_type_ID ); @@ -477,6 +479,7 @@ function init_by_kind( $kind, $name = NULL, $shortname = NULL, $urlname = NULL ) $this->set_setting( 'allow_rating_comment_helpfulness', 1 ); $this->set_setting( 'category_ordering', 'manual' ); $this->set_setting( 'disp_featured_above_list', 1 ); + $this->set_setting( 'download_enable', 0 ); // Try to find post type "Forum Topic" in DB global $DB; @@ -597,7 +600,7 @@ function load_from_Request( $groups = array() ) } if( $new_sec_ID != $this->get( 'sec_ID' ) ) { // If section has been changed to new: - if( ! $current_User->check_perm( 'blogs', 'create', false, $new_sec_ID ) ) + if( ! check_user_perm( 'blogs', 'create', false, $new_sec_ID ) ) { param_error( 'sec_ID', T_('You don\'t have a permission to create a collection in this section.') ); } @@ -893,6 +896,17 @@ function load_from_Request( $groups = array() ) // Tag posts per page: $this->set_setting( 'tag_posts_per_page', param( 'tag_posts_per_page', 'integer', NULL ), true ); + if( param( 'user_prefix', 'string', NULL ) !== NULL ) + { // User profile page prefix: + param_check_regexp( 'user_prefix', '#^[a-z0-9\-_]*$#i', sprintf( T_('User profile page prefix can contain only letters, digits, %s or %s.'), '-', '_' ) ); + $this->set_setting( 'user_prefix', get_param( 'user_prefix' ) ); + } + + if( param( 'user_links', 'string', NULL ) !== NULL ) + { // User profile URLs: + $this->set_setting( 'user_links', get_param( 'user_links' ) ); + } + if( param( 'single_links', 'string', NULL ) !== NULL ) { // Single post link type: $this->set_setting( 'single_links', get_param( 'single_links' ) ); @@ -967,7 +981,9 @@ function load_from_Request( $groups = array() ) } if( param( 'download_delay', 'integer', NULL ) !== NULL ) - { // Download delay + { // Enable Download pages: + $this->set_setting( 'download_enable', param( 'download_enable', 'integer', 0 ) ); + // Download delay param_check_range( 'download_delay', 0, 10, T_('Download delay must be numeric (0-10).') ); $this->set_setting( 'download_delay', get_param( 'download_delay' ) ); } @@ -1046,7 +1062,7 @@ function load_from_Request( $groups = array() ) $this->set_setting( 'post_categories', param( 'post_categories', 'string', NULL ) ); - if( $current_User->check_perm( 'blog_admin', 'edit', false, $this->ID ) ) + if( check_user_perm( 'blog_admin', 'edit', false, $this->ID ) ) { // We have permission to edit advanced admin settings: $this->set_setting( 'in_skin_editing', param( 'in_skin_editing', 'integer', 0 ) ); if( $this->get_setting( 'in_skin_editing' ) ) @@ -1088,6 +1104,9 @@ function load_from_Request( $groups = array() ) $this->set_setting( 'orderdir_2', param( 'orderdir_2', 'string', '' ) ); } + $postlist_enable = param( 'postlist_enable', 'integer', 0 ); + $this->set_setting( 'postlist_enable', $postlist_enable ); + $disp_featured_above_list = param( 'disp_featured_above_list', 'integer', 0 ); $this->set_setting( 'disp_featured_above_list', $disp_featured_above_list ); @@ -1227,11 +1246,12 @@ function load_from_Request( $groups = array() ) $this->set_setting( 'userdir_lastseen_cheat', param( 'userdir_lastseen_cheat', 'integer', 0 ) ); } - if( in_array( 'other', $groups ) ) - { // we want to load the other settings: + if( in_array( 'search', $groups ) ) + { // we want to load the search settings: // Search results: param_integer_range( 'search_per_page', 1, 9999, T_('Number of search results per page must be between %d and %d.') ); + $this->set_setting( 'search_enable', param( 'search_enable', 'integer', 0 ) ); $this->set_setting( 'search_per_page', get_param( 'search_per_page' ) ); $this->set_setting( 'search_sort_by', param( 'search_sort_by', 'string' ) ); $this->set_setting( 'search_include_cats', param( 'search_include_cats', 'integer', 0 ) ); @@ -1281,6 +1301,10 @@ function load_from_Request( $groups = array() ) $this->set_setting( 'search_result_template_file', param( 'search_result_template_file', 'string' ) ); $this->set_setting( 'search_result_template_category', param( 'search_result_template_category', 'string' ) ); $this->set_setting( 'search_result_template_tag', param( 'search_result_template_tag', 'string' ) ); + } + + if( in_array( 'other', $groups ) ) + { // we want to load the other settings: // Latest comments : param_integer_range( 'latest_comments_num', 1, 9999, T_('Number of shown comments must be between %d and %d.') ); @@ -1341,7 +1365,7 @@ function load_from_Request( $groups = array() ) $this->set_setting( 'allow_comments', param( 'allow_comments', 'string', 'any' ) ); $this->set_setting( 'allow_view_comments', param( 'allow_view_comments', 'string', 'any' ) ); $new_feedback_status = param( 'new_feedback_status', 'string', 'draft' ); - if( $new_feedback_status != $this->get_setting( 'new_feedback_status' ) && ( $new_feedback_status != 'published' || $current_User->check_perm( 'blog_admin', 'edit', false, $this->ID ) ) ) + if( $new_feedback_status != $this->get_setting( 'new_feedback_status' ) && ( $new_feedback_status != 'published' || check_user_perm( 'blog_admin', 'edit', false, $this->ID ) ) ) { // Only admin can set this setting to 'Public' $this->set_setting( 'new_feedback_status', $new_feedback_status ); } @@ -1359,12 +1383,12 @@ function load_from_Request( $groups = array() ) $this->set_setting( 'rating_question', param( 'rating_question', 'text' ) ); $this->set_setting( 'allow_rating_comment_helpfulness', param( 'allow_rating_comment_helpfulness', 'string', '0' ) ); $blog_allowtrackbacks = param( 'blog_allowtrackbacks', 'integer', 0 ); - if( $blog_allowtrackbacks != $this->get( 'allowtrackbacks' ) && ( $blog_allowtrackbacks == 0 || $current_User->check_perm( 'blog_admin', 'edit', false, $this->ID ) ) ) + if( $blog_allowtrackbacks != $this->get( 'allowtrackbacks' ) && ( $blog_allowtrackbacks == 0 || check_user_perm( 'blog_admin', 'edit', false, $this->ID ) ) ) { // Only admin can turn ON this setting $this->set( 'allowtrackbacks', $blog_allowtrackbacks ); } $blog_webmentions = param( 'blog_webmentions', 'integer', 0 ); - if( $blog_webmentions != $this->get_setting( 'webmentions' ) && ( $blog_webmentions == 0 || $current_User->check_perm( 'blog_admin', 'edit', false, $this->ID ) ) ) + if( $blog_webmentions != $this->get_setting( 'webmentions' ) && ( $blog_webmentions == 0 || check_user_perm( 'blog_admin', 'edit', false, $this->ID ) ) ) { // Only admin can turn ON this setting $this->set_setting( 'webmentions', $blog_webmentions ); } @@ -1447,6 +1471,7 @@ function load_from_Request( $groups = array() ) $this->set_setting( 'tags_structured_data', param( 'tags_structured_data', 'integer', 0 ) ); $this->set_setting( 'download_noindex', param( 'download_noindex', 'integer', 0 ) ); $this->set_setting( 'download_nofollowto', param( 'download_nofollowto', 'integer', 0 ) ); + $this->set_setting( 'canonical_user_urls', param( 'canonical_user_urls', 'integer', 0 ) ); } if( in_array( 'credits', $groups ) ) @@ -1462,8 +1487,8 @@ function load_from_Request( $groups = array() ) /* * ADVANCED ADMIN SETTINGS */ - if( $current_User->check_perm( 'blog_admin', 'edit', false, $this->ID ) || - ( $this->ID == 0 && $current_User->check_perm( 'blogs', 'create', false, $this->sec_ID ) ) ) + if( check_user_perm( 'blog_admin', 'edit', false, $this->ID ) || + ( $this->ID == 0 && check_user_perm( 'blogs', 'create', false, $this->sec_ID ) ) ) { // We have permission to edit advanced admin settings, // OR user is creating/coping new collection in section where he has an access: if( ( $blog_urlname = param( 'blog_urlname', 'string', NULL ) ) !== NULL ) @@ -1494,7 +1519,7 @@ function load_from_Request( $groups = array() ) } } } - if( $current_User->check_perm( 'blog_admin', 'edit', false, $this->ID ) ) + if( check_user_perm( 'blog_admin', 'edit', false, $this->ID ) ) { // We have permission to edit advanced admin settings: if( in_array( 'cache', $groups ) ) @@ -1740,7 +1765,7 @@ function load_from_Request( $groups = array() ) $this->set_setting( 'tinyurl_tag_extra_term', param( 'tinyurl_tag_extra_term', 'string', NULL ), true ); } - if( ( param( 'cookie_domain_type', 'string', NULL ) !== NULL ) && $current_User->check_perm( 'blog_admin', 'edit', false, $this->ID ) ) + if( ( param( 'cookie_domain_type', 'string', NULL ) !== NULL ) && check_user_perm( 'blog_admin', 'edit', false, $this->ID ) ) { // Cookies: $this->set_setting( 'cookie_domain_type', get_param( 'cookie_domain_type' ) ); if( get_param( 'cookie_domain_type' ) == 'custom' ) @@ -1774,7 +1799,7 @@ function load_from_Request( $groups = array() ) } } - if( ( param( 'rsc_assets_url_type', 'string', NULL ) !== NULL ) && $current_User->check_perm( 'blog_admin', 'edit', false, $this->ID ) ) + if( ( param( 'rsc_assets_url_type', 'string', NULL ) !== NULL ) && check_user_perm( 'blog_admin', 'edit', false, $this->ID ) ) { // Assets URLs / CDN: // Check all assets types url settings: @@ -2797,8 +2822,6 @@ function get_tag_link( $tag, $text = NULL, $attribs = array() ) */ function get_allowed_item_status( $status = NULL, $perm_target = NULL ) { - global $current_User; - if( ! is_logged_in() ) { // User must be logged in: return $this->get_max_allowed_status( $status ); @@ -2826,7 +2849,7 @@ function get_allowed_item_status( $status = NULL, $perm_target = NULL ) { // All next statuses are allowed for this collection: $max_status_is_allowed = true; } - if( $status_is_allowed && $max_status_is_allowed && $current_User->check_perm( 'blog_post!'.$status_key, 'create', false, $this->ID ) ) + if( $status_is_allowed && $max_status_is_allowed && check_user_perm( 'blog_post!'.$status_key, 'create', false, $this->ID ) ) { // This status is allowed for this collection and current has a permission: $allowed_status = $status_key; break; @@ -2904,7 +2927,7 @@ function get_default_cat_ID() */ function get_media_dir( $create = true ) { - global $media_path, $current_User, $Messages, $Settings, $Debuglog; + global $media_path, $Messages, $Settings, $Debuglog; if( ! $Settings->get( 'fm_enable_roots_blog' ) ) { // User directories are disabled: @@ -2936,7 +2959,7 @@ function get_media_dir( $create = true ) if( $create && ! is_dir( $mediadir ) ) { // Display absolute path to blog admin and relative path to everyone else - $msg_mediadir_path = ( is_logged_in() && $current_User->check_perm( 'blog_admin', 'edit', false, $this->ID ) ) ? $mediadir : rel_path_to_base( $mediadir ); + $msg_mediadir_path = check_user_perm( 'blog_admin', 'edit', false, $this->ID ) ? $mediadir : rel_path_to_base( $mediadir ); // TODO: Link to some help page(s) with errors! if( ! is_writable( dirname($mediadir) ) ) @@ -3160,10 +3183,9 @@ function get( $parname, $params = array() ) return $this->gen_baseurl(); case 'customizer_url': - if( is_logged_in() && - ( $current_User->check_perm( 'blog_properties', 'edit', false, $this->ID ) || - $Settings->get( 'site_skins_enabled' ) && $current_User->check_perm( 'options', 'edit' ) ) ) - { // Return customizer URL only if currnet User can edit skin settings of collection or site: + if( check_user_perm( 'blog_properties', 'edit', false, $this->ID ) || + ( $Settings->get( 'site_skins_enabled' ) && check_user_perm( 'options', 'edit' ) ) ) + { // Return customizer URL only if current User can edit skin settings of collection or site: if( ! empty( $params['customizing_url'] ) ) { // Get customizing URL from passed param: $customizing_url = $params['customizing_url']; @@ -3451,11 +3473,52 @@ function get( $parname, $params = array() ) } if( $this_Blog->get_setting( 'front_disp' ) == $disp_param ) - { // Get home page of this blog because front page displays current disp + { // Get home page of this blog because front page displays current disp: $url = $this_Blog->gen_blogurl( 'default' ); } + elseif( $disp_param == 'user' && ( isset( $params['user_login'] ) || isset( $params['user_ID'] ) ) ) + { // Use alias if user login or ID is provided: + $UserCache = & get_UserCache(); + if( ! isset( $params['user_ID'] ) && + ( $this_Blog->get_setting( 'user_links' ) == 'params' || $this_Blog->get_setting( 'user_links' ) == 'prefix_id' ) ) + { // We need get user ID by login: + if( $param_User = & $UserCache->get_by_login( $params['user_login'] ) ) + { // Set user ID if it is detected by login: + $params['user_ID'] = $param_User->ID; + } + else + { // Wrong request: + debug_die( 'Undefined param "user_ID" for Blog->get( "userurl" )' ); + } + } + if( ! isset( $params['user_login'] ) && + $this_Blog->get_setting( 'user_links' ) == 'prefix_login' ) + { // We need get user login by ID: + if( $param_User = & $UserCache->get_by_ID( $params['user_ID'], false, false ) ) + { // Use login if user is detected in DB: + $params['user_login'] = $param_User->get( 'login' ); + } + else + { // Wrong request: + debug_die( 'Undefined param "user_login" for Blog->get( "userurl" )' ); + } + } + + if( $this_Blog->get_setting( 'user_links' ) == 'params' || $this_Blog->get_setting( 'user_prefix' ) == '' ) + { // Use params E-g: ?disp=user&user_ID=4 + $url = url_add_param( $this_Blog->gen_blogurl(), 'disp=user'.$params['glue'].'user_ID='.$params['user_ID'], $params['glue'] ); + } + elseif( $this_Blog->get_setting( 'user_links' ) == 'prefix_id' ) + { // Use prefix with user ID: + $url = url_add_tail( $this_Blog->gen_blogurl(), '/'.$this_Blog->get_setting( 'user_prefix' ).':'.$params['user_ID'] ); + } + else // 'prefix_login' + { // Use prefix with user login: + $url = url_add_tail( $this_Blog->gen_blogurl(), '/'.$this_Blog->get_setting( 'user_prefix' ).':'.$params['user_login'] ); + } + } else - { // Add disp param to blog's url when current disp is not a front page + { // Add disp param to blog's url when current disp is not a front page: $url = url_add_param( $this_Blog->gen_blogurl(), 'disp='.$disp_param, $params['glue'] ); } @@ -3808,7 +3871,7 @@ function dbinsert() */ function create( $kind = '', $params = array() ) { - global $DB, $Messages, $basepath, $admin_url, $current_User, $Settings; + global $DB, $Messages, $basepath, $admin_url, $Settings; $params = array_merge( array( 'create_demo_contents' => false, @@ -3879,7 +3942,7 @@ function create( $kind = '', $params = array() ) load_funcs( 'collections/_demo_content.funcs.php' ); $user_org_IDs = NULL; - if( $params['create_demo_org'] && is_logged_in() && $current_User->check_perm( 'orgs', 'create', false ) ) + if( $params['create_demo_org'] && check_user_perm( 'orgs', 'create', false ) ) { // Create the demo organization if( $new_demo_organization = create_demo_organization( $this->get( 'owner_user_ID' ) ) ) { @@ -3908,8 +3971,7 @@ function create( $kind = '', $params = array() ) } // ADD DEFAULT WIDGETS: - load_funcs( 'widgets/_widgets.funcs.php' ); - insert_basic_widgets( $this->ID, 'normal', false, $kind ); + $this->setup_default_widgets(); $Messages->add_to_group( T_('Default widgets have been set-up for this collection.'), 'success', T_('New collection created:') ); @@ -4014,7 +4076,7 @@ function duplicate( $params = array() ) } $blog_urlname = param( 'blog_urlname', 'string', true ); - if( ! $current_User->check_perm( 'blog_admin', 'edit', false, $duplicated_coll_ID ) ) + if( ! check_user_perm( 'blog_admin', 'edit', false, $duplicated_coll_ID ) ) { // validate the urlname, which was already set by init_by_kind() function // It needs to validated, because the user can not set the blog urlname, and every new blog would have the same urlname without validation. // When user has edit permission to blog admin part, the urlname will be validated in load_from_request() function. @@ -5649,8 +5711,6 @@ function get_write_item_url( $cat_ID = 0, $post_title = '', $post_urltitle = '', ( ! is_logged_in() && $this->get_setting( 'post_anonymous' ) ) ) { // Only logged in and activated users can write a Post, // Or anonymous user can post if it is allowed with collection setting: - global $current_User; - $ChapterCache = & get_ChapterCache(); $selected_Chapter = $ChapterCache->get_by_ID( $cat_ID, false, false ); if( $selected_Chapter && @@ -5660,7 +5720,7 @@ function get_write_item_url( $cat_ID = 0, $post_title = '', $post_urltitle = '', return ''; } - if( ! is_logged_in() || $current_User->check_perm( 'blog_post_statuses', 'edit', false, $this->ID ) ) + if( ! is_logged_in() || check_user_perm( 'blog_post_statuses', 'edit', false, $this->ID ) ) { // We have permission to add a post with at least one status: if( $this->get_setting( 'in_skin_editing' ) && ! is_admin_page() ) { // We have a mode 'In-skin editing' for the current Blog @@ -5677,7 +5737,7 @@ function get_write_item_url( $cat_ID = 0, $post_title = '', $post_urltitle = '', } $url = url_add_param( $this->get( 'url' ), ( is_logged_in() ? 'disp=edit' : 'disp=anonpost' ).$cat_url_param ); } - elseif( is_logged_in() && $current_User->check_perm( 'admin', 'restricted' ) ) + elseif( check_user_perm( 'admin', 'restricted' ) ) { // Edit a post from Back-office global $admin_url; $url = $admin_url.'?ctrl=items&action=new&blog='.$this->ID; @@ -5727,10 +5787,8 @@ function get_create_chapter_url( $cat_ID = 0 ) if( is_logged_in( false ) ) { // Only logged in and activated users can write a Post - global $current_User; - - if( $current_User->check_perm( 'admin', 'restricted' ) && - $current_User->check_perm( 'blog_cats', 'edit', false, $this->ID ) ) + if( check_user_perm( 'admin', 'restricted' ) && + check_user_perm( 'blog_cats', 'edit', false, $this->ID ) ) { // Check permissions to create a new chapter in this blog global $admin_url; $url = $admin_url.'?ctrl=chapters&action=new&blog='.$this->ID; @@ -5829,9 +5887,7 @@ function check_access() } elseif( $allow_access == 'members' ) { // Check if current user is member of this blog - global $current_User; - - if( ! $current_User->check_perm( 'blog_ismember', 'view', false, $this->ID ) ) + if( ! check_user_perm( 'blog_ismember', 'view', false, $this->ID ) ) { // Force disp to restrict access for current user $disp = 'access_denied'; @@ -6041,31 +6097,33 @@ function can_be_item_type_disabled( $item_type_ID, $display_message = false ) return false; } + return true; + } + + + /** + * Check if this collection has items per requested Item Type + * + * @param integer Item Type ID + * @return boolean TRUE if at least one Item exists with given + */ + function has_items_per_item_type( $item_type_ID ) + { if( ! isset( $this->used_item_types ) ) - { // Get all item types that are used for posts in this collection: + { // Get all Item Types which are used for Items in this Collection: global $DB; - $coll_item_types_SQL = new SQL(); + $coll_item_types_SQL = new SQL( 'Get all Item Types which are used for Items of Collection #'.$this->ID ); $coll_item_types_SQL->SELECT( 'post_ityp_ID' ); $coll_item_types_SQL->FROM( 'T_items__item' ); $coll_item_types_SQL->FROM_add( 'INNER JOIN T_categories ON post_main_cat_ID = cat_ID' ); $coll_item_types_SQL->WHERE( 'cat_blog_ID = '.$this->ID ); $coll_item_types_SQL->GROUP_BY( 'post_ityp_ID' ); - $this->used_item_types = $DB->get_col( $coll_item_types_SQL->get() ); - } - - if( ! empty( $this->used_item_types ) && in_array( $item_type_ID, $this->used_item_types ) ) - { // Don't allow to disable an item type which is used at least for one post in this collection: - if( $display_message ) - { - global $Messages; - $Messages->add( 'This post type is used at least for one post in this collection. Thus you cannot disable it.', 'error' ); - } - return false; + $this->used_item_types = $DB->get_col( $coll_item_types_SQL ); } - return true; + return is_array( $this->used_item_types ) && in_array( $item_type_ID, $this->used_item_types ); } @@ -6107,6 +6165,7 @@ function enable_default_item_types() case 'forum': $default_post_types = array(); // Don't install the default Item Types(see above) for forums collection. $default_post_types[] = 'Forum Topic'; + $default_post_types[] = 'Task'; break; case 'manual': @@ -6114,8 +6173,8 @@ function enable_default_item_types() break; case 'group': - $default_post_types[] = 'Forum Topic'; - $default_post_types[] = 'Bug Report'; + $default_post_types = array(); // Don't install the default Item Types(see above) for Tracker collection. + $default_post_types[] = 'Task'; break; default: // 'std' @@ -6913,6 +6972,222 @@ function & get_default_ItemType() } + /** + * Setup default widgets for this collection + * + * @param string Skin type: 'all', 'normal', 'mobile', 'tablet' + * @param array Context + */ + function setup_default_widgets( $skin_type = 'all', $context = array() ) + { + global $DB; + + if( empty( $this->ID ) ) + { // This function should be called only for created collection: + return; + } + + if( $skin_type == 'all' ) + { // Setaup default widgets for skins of all types: + $this->setup_default_widgets( 'normal', $context ); + $this->setup_default_widgets( 'mobile', $context ); + $this->setup_default_widgets( 'tablet', $context ); + $this->setup_default_widgets( 'alt', $context ); + return; + } + + $coll_skin_ID = $this->get_skin_ID( $skin_type ); + $SkinCache = & get_SkinCache(); + if( ! ( $coll_Skin = & $SkinCache->get_by_ID( $coll_skin_ID, false, false ) ) ) + { // This collection must has a correct skin: + return; + } + + // Get the declarations of the widgets that the skin wants to use: + $context['current_coll_ID'] = $this->ID; + $skin_widgets = $coll_Skin->get_default_widgets( $this->get( 'type' ), $skin_type, $context ); + + // Check if the skin wants to use all b2evolution default widgets: + if( isset( $skin_widgets['*'] ) ) + { // Depending on how the skin want to use this: + $use_all_b2evo_default_widgets = $skin_widgets['*']; + unset( $skin_widgets['*'] ); + } + else + { // Use all default widgets if the skin does NOT say about this: + $use_all_b2evo_default_widgets = true; + } + + load_funcs( 'widgets/_widgets.funcs.php' ); + + // Get the declarations of the widgets that b2evolution recommends by default: + $b2evo_default_widgets = get_default_widgets( $this->get( 'type' ), $context ); + + // Merge the skin widget declarations with b2evolution default widgets: + foreach( $b2evo_default_widgets as $container_code => $widgets ) + { + if( // The skin has no widget declarations for this container and it allows to use b2evolution default widgets: + ( ! isset( $skin_widgets[ $container_code ] ) && + $use_all_b2evo_default_widgets ) + || + // The skin wants to use default widget declarations for this container: + ( isset( $skin_widgets[ $container_code ] ) && + $skin_widgets[ $container_code ] === true ) ) + { // Merge widgets from b2evolution default declarations to the skin: + $skin_widgets[ $container_code ] = $widgets; + } + elseif( isset( $skin_widgets[ $container_code ] ) && + is_array( $skin_widgets[ $container_code ] ) ) + { // Append custom skin widgets to default widgets: + $skin_widgets[ $container_code ] = array_merge( $widgets, $skin_widgets[ $container_code ] ); + } + } + + // Check all skin widget containers to be sure they all are proper arrays and not other values like true, false and etc.: + foreach( $skin_widgets as $container_code => $container_widgets ) + { + if( ! empty( $container_widgets['type'] ) && + ! in_array( $container_widgets['type'], array( 'main', 'sub', 'page' ) ) ) + { // Skip not collection container: + unset( $skin_widgets[ $container_code ] ); + continue; + } + if( isset( $container_widgets['coll_type'] ) && + ! is_allowed_option( $this->get( 'type' ), $container_widgets['coll_type'] ) ) + { // Skip container because it should not be installed for the given collection kind: + unset( $skin_widgets[ $container_code ] ); + continue; + } + + if( isset( $container_widgets['skin_type'] ) && + ! is_allowed_option( $skin_type, $container_widgets['skin_type'] ) ) + { // Skip container because it should not be installed for the given skin type: + unset( $skin_widgets[ $container_code ] ); + continue; + } + + if( $container_widgets === true ) + { // Set empty container if it has not been detected in b2evolution default widget declarations above: + $skin_widgets[ $container_code ] = array(); + } + elseif( ! is_array( $container_widgets ) ) + { // Ignore all other not array, probably it is a boolean false or some other string value which should be ignored indeed: + unset( $skin_widgets[ $container_code ] ); + } + } + + if( empty( $skin_widgets ) ) + { // No skin default widgets: + return; + } + + // Get all containers declared in this collection skin type: + $blog_containers = $this->get_skin_containers( $skin_type ); + + // Install additional sub-containers and page containers from default config, + // which are not declared as main containers but should be installed too: + foreach( $skin_widgets as $container_code => $container_widgets ) + { + if( isset( $container_widgets['type'] ) && + ( $container_widgets['type'] == 'sub' || $container_widgets['type'] == 'page' ) ) + { // If it is a sub-container or page container: + $blog_containers[ $container_code ] = array( + isset( $container_widgets['name'] ) ? $container_widgets['name'] : $container_code, + isset( $container_widgets['order'] ) ? $container_widgets['order'] : 1, + ( $container_widgets['type'] == 'sub' ? 0 : 1 ), // Main or Sub-container + isset( $container_widgets['item_ID'] ) ? $container_widgets['item_ID'] : NULL, + ); + } + } + + // Create rows to insert for all collection containers: + $widget_containers_sql_rows = array(); + foreach( $blog_containers as $container_code => $wico_data ) + { + $widget_containers_sql_rows[] = '( '.$DB->quote( $container_code ).', ' + .$DB->quote( $skin_type ).', ' + .$DB->quote( $wico_data[0] ).', ' + .$this->ID.', ' + .$DB->quote( $wico_data[1] ).', ' + .( isset( $wico_data[2] ) ? intval( $wico_data[2] ) : '1' ).', ' + .( isset( $wico_data[3] ) ? intval( $wico_data[3] ) : 'NULL' ).' )'; + } + + if( empty( $widget_containers_sql_rows ) ) + { // No collection containers to install: + return; + } + + // Insert widget containers records by one SQL query: + $DB->query( 'INSERT INTO T_widget__container ( wico_code, wico_skin_type, wico_name, wico_coll_ID, wico_order, wico_main, wico_item_ID ) VALUES' + .implode( ', ', $widget_containers_sql_rows ) ); + + $insert_id = $DB->insert_id; + foreach( $blog_containers as $container_code => $wico_data ) + { + $blog_containers[ $container_code ]['wico_ID'] = $insert_id; + $insert_id++; + } + + $basic_widgets_insert_sql_rows = array(); + foreach( $skin_widgets as $container_code => $container_widgets ) + { + if( ! isset( $blog_containers[ $container_code ] ) ) + { // Skip container which is not supported by current collection's skin: + continue; + } + + $wico_id = $blog_containers[ $container_code ]['wico_ID']; + + foreach( $container_widgets as $key => $widget ) + { + if( ! is_number( $key ) ) + { // Skip the config data which is used as additional info for container like 'type', 'name', 'order', 'item_ID', 'coll_type': + continue; + } + + if( isset( $widget['install'] ) && ! $widget['install'] ) + { // Skip widget because it should not be installed by condition from config: + continue; + } + + if( isset( $widget['coll_type'] ) && ! is_allowed_option( $this->get( 'type' ), $widget['coll_type'] ) ) + { // Skip widget because it should not be installed for the given collection kind: + continue; + } + + if( isset( $widget['is_pro'] ) && $widget['is_pro'] !== is_pro() ) + { // Skip widget because it should not be installed for the current version: + continue; + } + + if( isset( $widget['coll_ID'] ) && ! is_allowed_option( $this->ID, $widget['coll_ID'] ) ) + { // Skip widget because it should not be installed for the given collection ID: + continue; + } + + if( isset( $widget['skin_type'] ) && ! is_allowed_option( $skin_type, $widget['skin_type'] ) ) + { // Skip widget because it should not be installed for the given skin type: + continue; + } + + // Initialize a widget row to insert into DB below by single query: + $widget_type = isset( $widget['type'] ) ? $widget['type'] : 'core'; + $widget_params = isset( $widget['params'] ) ? ( is_array( $widget['params'] ) ? serialize( $widget['params'] ) : $widget['params'] ) : NULL; + $widget_enabled = isset( $widget['enabled'] ) ? intval( $widget['enabled'] ) : 1; + $basic_widgets_insert_sql_rows[] = '( '.$wico_id.', '.$widget[0].', '.$widget_enabled.', '.$DB->quote( $widget_type ).', '.$DB->quote( $widget[2] ).', '.$DB->quote( $widget_params ).' )'; + } + } + + // Check if there are widgets to create: + if( ! empty( $basic_widgets_insert_sql_rows ) ) + { // Insert the widget records by single SQL query: + $DB->query( 'INSERT INTO T_widget__widget ( wi_wico_ID, wi_order, wi_enabled, wi_type, wi_code, wi_params ) ' + .'VALUES '.implode( ', ', $basic_widgets_insert_sql_rows ) ); + } + } + + /** * Get name of default item type * @@ -7147,24 +7422,13 @@ function init_marketing_popup_container() $marketing_popup_show_frequency = $this->get_setting( 'marketing_popup_show_period_val' ) .$this->get_setting( 'marketing_popup_show_period_unit' ); } - echo ''; + expose_var_to_js( 'evo_ddexitpop_config', array( + 'container_code' => $marketing_popup_container_code, + 'animation' => $this->get_setting( 'marketing_popup_animation' ), + 'show_repeat' => (boolean)$this->get_setting( 'marketing_popup_show_repeat' ), + 'show_frequency' => $marketing_popup_show_frequency, + ) ); + require_js_defer( 'build/ddexitpop.bmin.js', 'blog', false, '#', 'footerlines' ); } } @@ -7227,18 +7491,18 @@ function get_mustread_items_count( $read_status = 'all' ) */ function get_link_locale_selector( $field_name, $locale, $restrict_used_locales = true ) { - global $DB, $current_User; + global $DB; if( $restrict_used_locales && ( $this->get( 'locale' ) == $locale || - in_array( $locale, $this->get_locales() ) ) ) + in_array( $locale, array_keys( $this->get_locales() ) ) ) ) { // Don't allow selector if this collection already uses the requested locale: return T_('N/A'); } $linked_colls = $this->get_locales( 'coll' ); - if( ! is_logged_in() || ! $current_User->check_perm( 'blogs', 'editall' ) ) + if( ! check_user_perm( 'blogs', 'editall' ) ) { // Display only the stored value because current User has no permission to edit all collections: if( isset( $linked_colls[ $locale ] ) ) { // Get the linked collection: @@ -7294,6 +7558,50 @@ function get_link_locale_selector( $field_name, $locale, $restrict_used_locales return $r; } + + + /** + * Reset widgets for this collection + * + * @param string Skin type: 'all', 'normal', 'mobile', 'tablet' + */ + function reset_widgets( $skin_type = 'all' ) + { + if( empty( $this->ID ) ) + { // This function should be called only for created collection: + return; + } + + global $DB; + + $all_skin_types = array( 'normal', 'mobile', 'tablet', 'alt' ); + + if( $skin_type == 'all' ) + { // Reset widgets for all skin types: + $skin_types = $all_skin_types; + } + elseif( in_array( $skin_type, $all_skin_types ) ) + { // Reset widgets only for requested skin type: + $skin_types = array( $skin_type ); + } + else + { // No correct skin type is requested: + return; + } + + foreach( $skin_types as $skin_type ) + { // Remove previous widgets: + $DB->query( 'DELETE T_widget__container, T_widget__widget + FROM T_widget__container + LEFT JOIN T_widget__widget ON wico_ID = wi_wico_ID + WHERE wico_coll_ID = '.$DB->quote( $this->ID ) + .( empty( $skin_type ) ? '' : + ' AND wico_skin_type = '.$DB->quote( $skin_type ) ) ); + + // Add default widgets: + $this->setup_default_widgets( $skin_type ); + } + } } ?> diff --git a/inc/collections/model/_blog.funcs.php b/inc/collections/model/_blog.funcs.php index 459834a67fb..9157f421c3e 100644 --- a/inc/collections/model/_blog.funcs.php +++ b/inc/collections/model/_blog.funcs.php @@ -15,6 +15,54 @@ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); +/** + * Check if permission is always enabled + * + * @param object the db row + * @param string the prefix of the db row: 'bloguser_' or 'bloggroup_' + * @param string permission name + * @param string Collection owner user ID + * @return boolean + */ +function is_always_coll_perm_enabled( $row, $prefix, $perm, $coll_owner_user_ID ) +{ + if( $prefix == 'bloguser_' && $perm != 'perm_admin' && $coll_owner_user_ID == $row->user_ID ) + { // Collection owner has almost all permissions by default (One exception is "admin" perm to edit advanced/administrative coll properties): + return true; + } + + // Check if permission is always enabled by group setting: + if( ! empty( $row->user_ID ) ) + { // User perm: + $UserCache = & get_UserCache(); + if( $User = & $UserCache->get_by_ID( $row->user_ID, false, false ) ) + { // Get user group: + $perm_Group = & $User->get_Group(); + } + } + elseif( ! empty( $row->grp_ID ) ) + { // Group perm: + $GroupCache = & get_GroupCache(); + $perm_Group = & $GroupCache->get_by_ID( $row->grp_ID, false, false ); + } + + if( ! empty( $perm_Group ) ) + { // Check global group setting permission: + $group_perm_blogs = $perm_Group->get( 'perm_blogs' ); + if( $group_perm_blogs == 'editall' ) + { // If the group has a global permission to edit ALL collections: + return true; + } + elseif( $perm == 'ismember' && $group_perm_blogs == 'viewall' ) + { // If the group has a global permission to view or edit ALL collections: + return true; + } + } + + return false; +} + + /** * Update the advanced user/group permissions for edited blog * @@ -25,11 +73,6 @@ function blog_update_perms( $object_ID, $context = 'user' ) { global $DB; - /** - * @var User - */ - global $current_User; - // Get affected user/group IDs: $IDs = param( $context.'_IDs', '/^[0-9]+(,[0-9]+)*$/', '' ); $ID_array = explode( ',', $IDs ); @@ -68,7 +111,7 @@ function blog_update_perms( $object_ID, $context = 'user' ) foreach( $coll_IDs as $coll_ID ) { // Can the current user touch advanced admin permissions? - if( ! $current_User->check_perm( 'blog_admin', 'edit', false, $coll_ID ) ) + if( ! check_user_perm( 'blog_admin', 'edit', false, $coll_ID ) ) { // We have no permission to touch advanced admins! // Get the users/groups which are advanced admins @@ -88,6 +131,9 @@ function blog_update_perms( $object_ID, $context = 'user' ) return; } + $BlogCache = & get_BlogCache(); + $BlogCache->load_list( $coll_IDs ); + // Delete old perms for the edited collection/group: $DB->query( "DELETE FROM $table WHERE {$ID_field_edit} IN (".implode( ',',$ID_array ).") @@ -95,7 +141,7 @@ function blog_update_perms( $object_ID, $context = 'user' ) $inserted_values = array(); foreach( $ID_array as $loop_ID ) - { // Check new permissions for each user: + { // Check new permissions per each user or group or collection: // Get collection/object ID depedning on request: $coll_ID = ( $context == 'coll' ? $loop_ID : $blog ); @@ -159,7 +205,7 @@ function blog_update_perms( $object_ID, $context = 'user' ) $perm_cats = param( 'blog_perm_cats_'.$loop_ID, 'integer', 0 ); $perm_properties = param( 'blog_perm_properties_'.$loop_ID, 'integer', 0 ); - if( $current_User->check_perm( 'blog_admin', 'edit', false, $coll_ID ) ) + if( check_user_perm( 'blog_admin', 'edit', false, $coll_ID ) ) { // We have permission to give advanced admins perm! $perm_admin = param( 'blog_perm_admin_'.$loop_ID, 'integer', 0 ); } @@ -176,10 +222,22 @@ function blog_update_perms( $object_ID, $context = 'user' ) // Update those permissions in DB: - if( $ismember || $can_be_assignee || $workflow_status || $workflow_user || $workflow_priority || + // Update permissions per user or group or collection if at least on is selected: + $update_permissions = ( $ismember || $can_be_assignee || $workflow_status || $workflow_user || $workflow_priority || $perm_item_propose || count($perm_post) || $perm_delpost || $perm_edit_ts || $perm_delcmts || $perm_recycle_owncmts || $perm_vote_spam_comments || $perm_cmtstatuses || - $perm_meta_comments || $perm_cats || $perm_properties || $perm_admin || $perm_media_upload || $perm_media_browse || $perm_media_change || $perm_analytics ) - { // There are some permissions for this user: + $perm_meta_comments || $perm_cats || $perm_properties || $perm_admin || $perm_media_upload || $perm_media_browse || $perm_media_change || $perm_analytics ); + if( ! $update_permissions && + ( $perm_Blog = & $BlogCache->get_by_ID( $coll_ID, false, false ) ) ) + { // When all permissions are disabled(not checked), + // do additional check for users or groups which are always members of the Collection: + $null_row = ( $context == 'user' + ? array( 'user_ID' => $loop_ID ) + : array( 'grp_ID' => ( $context == 'coll' ? $group_ID : $loop_ID ) ) ); + $update_permissions = is_always_coll_perm_enabled( (object)$null_row, $prefix, 'can_be_assignee', $perm_Blog->get( 'owner_user_ID' ) ); + } + + if( $update_permissions ) + { // Initialize value to update permissions: $ismember = 1; // Must have this permission // insert new perms: @@ -291,7 +349,7 @@ function autoselect_blog( $permname, $permlevel = 'any' ) if( $autoselected_blog ) { // a blog is already selected - if( !$current_User->check_perm( $permname, $permlevel, false, $autoselected_blog ) ) + if( ! check_user_perm( $permname, $permlevel, false, $autoselected_blog ) ) { // invalid blog // echo 'current blog was invalid'; $autoselected_blog = 0; @@ -355,7 +413,7 @@ function valid_blog_requested() */ function get_working_blog() { - global $blog, $current_User, $UserSettings; + global $blog, $UserSettings; if( ! is_logged_in() ) { // User must be logged in to view the blogs @@ -365,7 +423,7 @@ function get_working_blog() if( ! empty( $blog ) ) { // Use a blog from GET request $blog_ID = intval( $blog ); - if( $blog_ID > 0 && $current_User->check_perm( 'blog_ismember', 'view', false, $blog_ID ) ) + if( $blog_ID > 0 && check_user_perm( 'blog_ismember', 'view', false, $blog_ID ) ) { // Allow to use this blog only when current user has an access to view it return $blog_ID; } @@ -377,7 +435,7 @@ function get_working_blog() $blog_ID = intval( $UserSettings->get( 'selected_blog' ) ); // Check if it really exists in DB $selected_Blog = & $BlogCache->get_by_ID( $blog_ID, false, false ); - if( $selected_Blog && $current_User->check_perm( 'blog_ismember', 'view', false, $selected_Blog->ID ) ) + if( $selected_Blog && check_user_perm( 'blog_ismember', 'view', false, $selected_Blog->ID ) ) { // Allow to use this blog only when current user is a member of it return $blog_ID; } @@ -621,14 +679,13 @@ function set_cache_enabled( $cache_key, $new_status, $coll_ID = NULL, $save_sett * Identify requested collection & initialize global $blog variable to the requested collection * This is when we go through index.php (NOT through stub file). * - * @param boolean $use_blog_param_first is used in _init_login.php --> fp>yb: WHY do we need that? * @param boolean try to identify a TinySlug before trying to identify a collection * @param boolean if the domain does not match a collection, try to process as a TinyURL and redirect before fallback to default collection * @return boolean true if $blog was initialized successful, false otherwise */ function init_requested_coll_or_process_tinyurl( $process_tinyslug_first = true, $process_unknown_domain_as_tinyurl = true ) { - global $blog, $ReqHost, $sanitized_ReqPath, $baseurl, $pagenow; + global $blog, $ReqHost, $ReqURL, $sanitized_ReqPath, $baseurl, $pagenow; global $Settings; global $Debuglog; global $resolve_extra_path, $slug_extra_term; @@ -799,7 +856,7 @@ function init_requested_coll_or_process_tinyurl( $process_tinyslug_first = true, $Debuglog->add( 'Found matching collection: '.$blog. 'using alias '.$alias, 'url_decode_part_1' ); // Find tail from the currently requested alias URL: $same_protocol_alias = url_same_protocol( $alias, $ReqAbsUrl ); - $tail_Path = str_replace( $same_protocol_alias, '', $ReqAbsUrl ); + $tail_Path = str_replace( $same_protocol_alias, '', $ReqURL ); if( substr( $tail_Path, 0, 1 ) != '/' ) { // Tail must start with '/' $tail_Path = '/'.$tail_Path; @@ -943,9 +1000,9 @@ function init_blog_widgets( $blog_id ) */ function check_allow_disp( $disp ) { - global $Collection, $Blog, $Messages, $Settings, $current_User; + global $Collection, $Blog, $Messages; - if( !check_user_status( 'can_be_validated' ) ) + if( ! check_user_status( 'can_be_validated' ) ) { // we don't have the case when user is logged in and the account is not active return; } @@ -963,44 +1020,44 @@ function check_allow_disp( $disp ) return; break; // already exited before this case 'contacts': - if( !$current_User->check_status( 'can_view_contacts' ) ) + if( ! check_user_status( 'can_view_contacts' ) ) { // contacts view display is not allowed return; } break; case 'edit': - if( !$current_User->check_status( 'can_edit_post' ) ) + if( ! check_user_status( 'can_edit_post' ) ) { // edit post is not allowed return; } break; case 'messages': - if( !$current_User->check_status( 'can_view_messages' ) ) + if( ! check_user_status( 'can_view_messages' ) ) { // messages view display is not allowed return; } break; case 'msgform': - if( !$current_User->check_status( 'can_view_msgform' ) ) + if( ! check_user_status( 'can_view_msgform' ) ) { // msgform display is not allowed return; } break; case 'threads': - if( !$current_User->check_status( 'can_view_threads' ) ) + if( ! check_user_status( 'can_view_threads' ) ) { // threads view display is not allowed return; } break; case 'user': $user_ID = param( 'user_ID', 'integer', '', true ); - if( !$current_User->check_status( 'can_view_user', $user_ID ) ) + if( ! check_user_status( 'can_view_user', $user_ID ) ) { // user profile display is not allowed return; } break; case 'users': - if( !$current_User->check_status( 'can_view_users' ) ) + if( ! check_user_status( 'can_view_users' ) ) { // not active user can't see users list return; } @@ -1112,7 +1169,7 @@ function get_highest_publish_status( $type, $blog, $with_label = true, $restrict { // This is first allowed status, then all next statuses are also allowed: $status_is_allowed = true; } - if( $restricted_status_is_allowed && $status_is_allowed && $current_User->check_perm( 'blog_'.$type.'!'.$curr_status, 'create', false, $blog ) ) + if( $restricted_status_is_allowed && $status_is_allowed && check_user_perm( 'blog_'.$type.'!'.$curr_status, 'create', false, $blog ) ) { // The highest available publish status has been found: $result = $curr_status; break; @@ -1121,7 +1178,7 @@ function get_highest_publish_status( $type, $blog, $with_label = true, $restrict if( ! $result ) { // There are no available public status: - if( $current_User->check_perm( 'blog_'.$type.'!private', 'create', false, $blog ) ) + if( check_user_perm( 'blog_'.$type.'!private', 'create', false, $blog ) ) { // Check private status: $result = 'private'; } @@ -1498,10 +1555,9 @@ function get_visibility_statuses( $format = '', $exclude = array('trash'), $chec if( $check_perms && ! is_null( $blog_ID ) ) { // Check what status is available for current user - global $current_User; foreach( $r as $status_key => $status_title ) { - if( ! $current_User->check_perm( 'blog_post!'.$status_key, 'create', false, $blog_ID ) ) + if( ! check_user_perm( 'blog_post!'.$status_key, 'create', false, $blog_ID ) ) { // Unset this status from list because current user has no perms to use this status unset( $r[ $status_key ] ); } @@ -1569,8 +1625,6 @@ function compare_visibility_status( $first_status, $second_status ) */ function get_restricted_statuses( $blog_ID, $prefix, $permlevel = 'view', $allow_statuses = '', $restrict_max_allowed_status = '', $perm_target = NULL ) { - global $current_User; - $result = array(); // Get max allowed visibility status: @@ -1599,7 +1653,7 @@ function get_restricted_statuses( $blog_ID, $prefix, $permlevel = 'view', $allow { // Keep these statuses in array only to set $status_is_allowed in order to know when we can start allow the statuses: continue; } - if( ( ! in_array( $status, $allow_statuses ) && ! $status_is_allowed ) || ! ( is_logged_in() && $current_User->check_perm( $prefix.$status, 'create', false, $blog_ID ) ) ) + if( ( ! in_array( $status, $allow_statuses ) && ! $status_is_allowed ) || ! check_user_perm( $prefix.$status, 'create', false, $blog_ID ) ) { // This status is not allowed $result[] = $status; } @@ -1607,13 +1661,13 @@ function get_restricted_statuses( $blog_ID, $prefix, $permlevel = 'view', $allow // 'redirected' status is allowed to view/edit only in case of posts, and only if user has permission if( $prefix == 'blog_comment!' || - ( $prefix == 'blog_post!' && ! ( is_logged_in() && $current_User->check_perm( $prefix.'redirected', 'create', false, $blog_ID ) ) ) ) + ( $prefix == 'blog_post!' && ! check_user_perm( $prefix.'redirected', 'create', false, $blog_ID ) ) ) { // not allowed $result[] = 'redirected'; } // 'trash' status is allowed only in case of comments, and only if user has a permission to delete a comment from the given collection - if( $prefix == 'blog_comment!' && ! ( is_logged_in() && ! empty( $perm_target ) && $current_User->check_perm( 'comment!CURSTATUS', 'delete', false, $perm_target ) ) ) + if( $prefix == 'blog_comment!' && ! ( ! empty( $perm_target ) && check_user_perm( 'comment!CURSTATUS', 'delete', false, $perm_target ) ) ) { // not allowed $result[] = 'trash'; } @@ -1630,7 +1684,7 @@ function get_restricted_statuses( $blog_ID, $prefix, $permlevel = 'view', $allow $status_is_allowed = true; } if( ( ! in_array( $status, $allow_statuses ) && ! $status_is_allowed ) || - ! ( is_logged_in() && $current_User->check_perm( $prefix.$status, 'create', false, $blog_ID ) ) ) + ! check_user_perm( $prefix.$status, 'create', false, $blog_ID ) ) { // This status is not allowed $result[] = $status; } @@ -1675,7 +1729,6 @@ function can_be_displayed_with_status( $status, $type, $blog_ID, $creator_user_I } global $current_User; - $is_logged_in = is_logged_in( false ); $permname = ( $type == 'item' ? 'blog_post!' : 'blog_comment!' ).$status; @@ -1688,18 +1741,18 @@ function can_be_displayed_with_status( $status, $type, $blog_ID, $creator_user_I case 'community': // It is always allowed for logged in users: - $allowed = $is_logged_in; + $allowed = is_logged_in( false ); break; case 'protected': // It is always allowed for members: - $allowed = ( $is_logged_in && $current_User->check_perm( 'blog_ismember', 1, false, $blog_ID ) ); + $allowed = check_user_perm( 'blog_ismember', 1, false, $blog_ID, false ); break; case 'private': // It is allowed for users who has global 'editall' permission: - $allowed = ( $is_logged_in && $current_User->check_perm( 'blogs', 'editall' ) ); - if( ! $allowed && $is_logged_in && $current_User->check_perm( $permname, 'create', false, $blog_ID ) ) + $allowed = check_user_perm( 'blogs', 'editall', false, NULL, false ); + if( ! $allowed && check_user_perm( $permname, 'create', false, $blog_ID, false ) ) { // Own private items/comments are allowed if user can create private items/comments: $allowed = ( $current_User->ID == $creator_user_ID ); } @@ -1707,8 +1760,8 @@ function can_be_displayed_with_status( $status, $type, $blog_ID, $creator_user_I case 'review': // It is allowed for users who have at least 'lt' items/comments edit permission : - $allowed = ( $is_logged_in && $current_User->check_perm( $permname, 'moderate', false, $blog_ID ) ); - if( ! $allowed && $is_logged_in && $current_User->check_perm( $permname, 'create', false, $blog_ID ) ) + $allowed = check_user_perm( $permname, 'moderate', false, $blog_ID, false ); + if( ! $allowed && check_user_perm( $permname, 'create', false, $blog_ID, false ) ) { // Own items/comments with 'review' status are allowed if user can create items/comments with 'review' status $allowed = ( $current_User->ID == $creator_user_ID ); } @@ -1716,7 +1769,7 @@ function can_be_displayed_with_status( $status, $type, $blog_ID, $creator_user_I case 'draft': // In front-office only authors may see their own draft items/comments, but only if the have permission to create draft items/comments: - $allowed = ( $is_logged_in && $current_User->check_perm( $permname, 'create', false, $blog_ID ) + $allowed = ( check_user_perm( $permname, 'create', false, $blog_ID, false ) && $current_User->ID == $creator_user_ID ); break; @@ -1783,7 +1836,7 @@ function & get_setting_Blog( $setting_name, $current_Blog = NULL, $halt_on_error */ function get_coll_fav_icon( $blog_ID, $params = array() ) { - global $admin_url, $current_User; + global $admin_url; $params = array_merge( array( 'title' => '', @@ -1956,13 +2009,7 @@ function blogs_user_results_block( $params = array() ) 'action' => '', ), $params ); - if( !is_logged_in() ) - { // Only logged in users can access to this function - return; - } - - global $current_User; - if( !$current_User->check_perm( 'users', 'moderate' ) || !$current_User->check_perm( 'blogs', 'view' ) ) + if( ! check_user_perm( 'users', 'moderate' ) || ! check_user_perm( 'blogs', 'view' ) ) { // Check minimum permission: return; } @@ -2071,16 +2118,16 @@ function callback_filter_collectionlist( & $Form ) */ function blogs_all_results_block( $params = array() ) { - global $admin_url, $current_User, $DB, $Session; + global $admin_url, $DB, $Session; global $cf_name, $cf_owner, $cf_type; // Make sure we are not missing any param: $params = array_merge( array( 'results_param_prefix' => 'blog_', - 'results_title' => $current_User->check_perm( 'blog_admin', 'view', false ) ? T_('List of Collections configured on this system').get_manual_link('site-collection-list') : T_('Your Collections'), + 'results_title' => check_user_perm( 'blog_admin', 'view', false ) ? T_('List of Collections configured on this system').get_manual_link('site-collection-list') : T_('Your Collections'), 'results_no_text' => T_('Create your first collection now').': ' .' '.T_('New Collection').'...', - 'results_no_perm_text' => ( $current_User->check_perm( 'blogs', 'create' ) + 'results_no_perm_text' => ( check_user_perm( 'blogs', 'create' ) ? T_('Create your first collection now').': '.action_icon( T_('New Collection').'...', 'new', $admin_url.'?ctrl=collections&action=new', T_('New Collection').'...', 3, 4, array( 'class' => 'action_icon btn btn-primary', 'style' => 'margin:-10px 0 -7px 0' ) ) : T_('Sorry, you have no permission to edit/view any collection\'s properties.') ), 'grouped' => true, @@ -2154,7 +2201,7 @@ function blogs_all_results_block( $params = array() ) $BlogCache = & get_BlogCache(); if( $updated_Blog = & $BlogCache->get_by_ID( $order_obj_ID, false ) ) { - if( $current_User->check_perm( 'blog_properties', 'edit', false, $updated_Blog->ID ) ) + if( check_user_perm( 'blog_properties', 'edit', false, $updated_Blog->ID ) ) { // If current user can edit the collection: $updated_Blog->set( 'order', $new_value ); $updated_Blog->dbupdate(); @@ -2171,7 +2218,7 @@ function blogs_all_results_block( $params = array() ) $SectionCache = & get_SectionCache(); if( $updated_Section = & $SectionCache->get_by_ID( $order_obj_ID, false ) ) { - if( $current_User->check_perm( 'section', 'edit', false, $order_obj_ID ) ) + if( check_user_perm( 'section', 'edit', false, $order_obj_ID ) ) { // If current user can edit the requested section: $updated_Section->set( 'order', $new_value ); $updated_Section->dbupdate(); @@ -2200,7 +2247,7 @@ function blogs_all_results_block( $params = array() ) $SQL->FROM_add( 'LEFT JOIN T_coll_user_favs ON ( cufv_blog_ID = blog_ID AND cufv_user_ID = '.$current_User->ID.' )' ); $SQL->FROM_add( 'LEFT JOIN T_coll_settings ON blog_ID = cset_coll_ID AND cset_name = "collection_logo_file_ID"' ); - if( ! $current_User->check_perm( 'blogs', 'view' ) ) + if( ! check_user_perm( 'blogs', 'view' ) ) { // We do not have perm to view all blogs... we need to restrict to those we're a member of: $SQL->FROM_add( 'LEFT JOIN T_coll_user_perms ON ( blog_advanced_perms <> 0 AND blog_ID = bloguser_blog_ID' . ' AND bloguser_user_ID = ' . $current_User->ID . ' )' ); @@ -2263,11 +2310,11 @@ function blogs_all_results_block( $params = array() ) $blogs_Results->register_filter_preset( 'all', T_('All'), '?ctrl=collections&cf_type=&cf_name=&cf_owner=' ); global $admin_url; - if( $current_User->check_perm( 'section', 'edit' ) ) + if( check_user_perm( 'section', 'edit' ) ) { // Display a button to create new section only if Current user has a permission for this action: $blogs_Results->global_icon( T_('New Section').'...', 'new', url_add_param( $admin_url, 'ctrl=collections&action=new_section' ), T_('New Section').'...', 3, 4, array( 'class' => 'action_icon btn-primary' ) ); } - if( $current_User->check_perm( 'blogs', 'create' ) ) + if( check_user_perm( 'blogs', 'create' ) ) { // Display a button to create new collection only if Current user has a permission to create this in default section: $blogs_Results->global_icon( T_('New Collection').'...', 'new', url_add_param( $admin_url, 'ctrl=collections&action=new' ), T_('New Collection').'...', 3, 4, array( 'class' => 'action_icon btn-primary' ) ); } @@ -2300,7 +2347,7 @@ function blogs_all_results_block( $params = array() ) */ function blogs_model_results_block( $params = array() ) { - global $admin_url, $current_User, $DB; + global $admin_url, $DB; // Make sure we are not missing any param: $params = array_merge( array( @@ -2309,7 +2356,7 @@ function blogs_model_results_block( $params = array() ) 'results_no_text' => T_('No model available'), ), $params ); - if( ! is_logged_in() || ! $current_User->check_perm( 'blogs', 'create' ) ) + if( ! check_user_perm( 'blogs', 'create' ) ) { // Only logged in users which can create new collections can access this function return; } @@ -2321,9 +2368,7 @@ function blogs_model_results_block( $params = array() ) return; } - $is_coll_admin = $current_User->check_perm( 'blog_admin', 'editAll' ); - - global $current_User; + $is_coll_admin = check_user_perm( 'blog_admin', 'editAll' ); if( is_ajax_content() ) { @@ -2339,7 +2384,7 @@ function blogs_model_results_block( $params = array() ) $BlogCache = & get_BlogCache(); if( $updated_Blog = & $BlogCache->get_by_ID( $order_obj_ID, false ) ) { - if( $current_User->check_perm( 'blog_properties', 'edit', false, $updated_Blog->ID ) ) + if( check_user_perm( 'blog_properties', 'edit', false, $updated_Blog->ID ) ) { // Check permission to edit this Blog $updated_Blog->set( 'order', $new_value ); $updated_Blog->dbupdate(); @@ -2364,7 +2409,7 @@ function blogs_model_results_block( $params = array() ) $blogs_Results->title = $params['results_title']; $blogs_Results->no_results_text = $no_results; - if( $current_User->check_perm( 'blogs', 'create' ) ) + if( check_user_perm( 'blogs', 'create' ) ) { global $admin_url; //$blogs_Results->global_icon( T_('New Collection').'...', 'new', url_add_param( $admin_url, 'ctrl=collections&action=new' ), T_('New Collection').'...', 3, 4, array( 'class' => 'action_icon btn-primary' ) ); @@ -2501,8 +2546,6 @@ function blogs_results( & $blogs_Results, $params = array() ) if( $params['grouped'] ) { // Display group rows: - global $current_User, $admin_url; - $blogs_Results->group_by = 'sec_ID'; $blogs_Results->ID_col = 'blog_ID'; @@ -2646,9 +2689,9 @@ function blogs_results( & $blogs_Results, $params = array() ) */ function blog_row_group_name( $sec_ID, $sec_name ) { - global $current_User, $admin_url; + global $admin_url; - if( $current_User->check_perm( 'section', 'view', false, $sec_ID ) ) + if( check_user_perm( 'section', 'view', false, $sec_ID ) ) { // If user can view the section: $sec_name = ''.$sec_name.''; } @@ -2665,15 +2708,15 @@ function blog_row_group_name( $sec_ID, $sec_name ) */ function blog_row_name( $coll_name, $coll_ID ) { - global $current_User, $ctrl, $admin_url; - if( $ctrl == 'dashboard' && $current_User->check_perm( 'blog_ismember', 'view', false, $coll_ID ) ) + global $ctrl, $admin_url; + if( $ctrl == 'dashboard' && check_user_perm( 'blog_ismember', 'view', false, $coll_ID ) ) { // Dashboard $edit_url = $admin_url.'?ctrl=coll_settings&tab=dashboard&blog='.$coll_ID; $r = ''; $r .= $coll_name; $r .= ''; } - elseif( $current_User->check_perm( 'blog_properties', 'edit', false, $coll_ID ) ) + elseif( check_user_perm( 'blog_properties', 'edit', false, $coll_ID ) ) { // Blog setting & can edit $edit_url = $admin_url.'?ctrl=coll_settings&blog='.$coll_ID; $r = ''; @@ -2697,11 +2740,11 @@ function blog_row_name( $coll_name, $coll_ID ) */ function blog_row_fullname( $coll_fullname, $coll_ID ) { - global $current_User, $admin_url; + global $admin_url; $coll_fullname = strmaxlen( $coll_fullname, 40, NULL, 'raw' ); - if( $current_User->check_perm( 'blog_properties', 'edit', false, $coll_ID ) ) + if( check_user_perm( 'blog_properties', 'edit', false, $coll_ID ) ) { // Blog setting & can edit $edit_url = $admin_url.'?ctrl=coll_settings&tab=general&blog='.$coll_ID; $r = ''; @@ -2726,7 +2769,7 @@ function blog_row_fullname( $coll_fullname, $coll_ID ) */ function blog_row_type( $coll_type, $coll_ID ) { - global $current_User, $admin_url, $Settings; + global $admin_url, $Settings; $type_titles = array( 'minisite' => T_('Mini-Site'), @@ -2740,7 +2783,7 @@ function blog_row_type( $coll_type, $coll_ID ) $type_title = isset( $type_titles[ $coll_type ] ) ? $type_titles[ $coll_type ] : $coll_type; - if( $current_User->check_perm( 'blog_properties', 'edit', false, $coll_ID ) ) + if( check_user_perm( 'blog_properties', 'edit', false, $coll_ID ) ) { // Blog setting & can edit $edit_url = $admin_url.'?ctrl=coll_settings&tab=general&action=type&blog='.$coll_ID; $r = ''; @@ -2784,11 +2827,11 @@ function blog_row_type( $coll_type, $coll_ID ) */ function blog_row_locale( $coll_locale, $coll_ID ) { - global $current_User, $admin_url; + global $admin_url; $coll_locale = locale_flag( $coll_locale, NULL, NULL, NULL, false ); - if( $current_User->check_perm( 'blog_properties', 'edit', false, $coll_ID ) ) + if( check_user_perm( 'blog_properties', 'edit', false, $coll_ID ) ) { // Blog setting & can edit $edit_url = $admin_url.'?ctrl=coll_settings&blog='.$coll_ID; $r = ''; @@ -2813,9 +2856,9 @@ function blog_row_locale( $coll_locale, $coll_ID ) */ function blog_row_order( $blog_ID, $blog_order ) { - global $current_User, $admin_url; + global $admin_url; - if( $current_User->check_perm( 'blog_properties', 'edit', false, $blog_ID ) ) + if( check_user_perm( 'blog_properties', 'edit', false, $blog_ID ) ) { // Blog setting & can edit $edit_url = $admin_url.'?ctrl=coll_settings&tab=general&blog='.$blog_ID.'#blog_order'; $r = ''; @@ -2839,9 +2882,9 @@ function blog_row_order( $blog_ID, $blog_order ) */ function blog_row_group_order( $sec_ID, $sec_order ) { - global $current_User, $admin_url; + global $admin_url; - if( $current_User->check_perm( 'section', 'edit', false, $sec_ID ) ) + if( check_user_perm( 'section', 'edit', false, $sec_ID ) ) { // Only if current user has a permission to edit sections: $edit_url = $admin_url.'?ctrl=collections&action=edit_section&sec_ID='.$sec_ID; $r = ''; @@ -2865,7 +2908,7 @@ function blog_row_group_order( $sec_ID, $sec_order ) */ function blog_row_caching( $Blog ) { - global $current_User, $admin_url; + global $admin_url; // Get icon and title for page caching status if( $Blog->get_setting( 'cache_enabled' ) ) @@ -2899,7 +2942,7 @@ function blog_row_caching( $Blog ) $before = ''; $after = ''; - if( $current_User->check_perm( 'blog_properties', 'edit', false, $Blog->ID ) ) + if( check_user_perm( 'blog_properties', 'edit', false, $Blog->ID ) ) { // User has a permission to edit blog settings $toggle_url = $admin_url.'?ctrl=coll_settings' .'&tab=general' @@ -2928,7 +2971,7 @@ function blog_row_caching( $Blog ) */ function blog_row_listed( $value, $coll_ID ) { - global $current_User, $admin_url; + global $admin_url; switch( $value ) { @@ -2949,7 +2992,7 @@ function blog_row_listed( $value, $coll_ID ) break; } - if( $current_User->check_perm( 'blog_properties', 'edit', false, $coll_ID ) ) + if( check_user_perm( 'blog_properties', 'edit', false, $coll_ID ) ) { // Blog setting & can edit $edit_url = $admin_url.'?ctrl=coll_settings&blog='.$coll_ID; $r = ''; @@ -2976,7 +3019,7 @@ function blog_row_listed( $value, $coll_ID ) */ function blog_row_setting( $blog_ID, $setting_name, $setting_value ) { - global $current_User, $admin_url; + global $admin_url; switch( $setting_name ) { @@ -3007,18 +3050,18 @@ function blog_row_setting( $blog_ID, $setting_name, $setting_value ) */ function blog_row_actions( $Blog, $sec_ID ) { - global $current_User, $admin_url; + global $admin_url; $r = ''.T_('View').''; - if( $current_User->check_perm( 'blog_properties', 'edit', false, $Blog->ID ) ) + if( check_user_perm( 'blog_properties', 'edit', false, $Blog->ID ) ) { // If user can edit collection properties: $r .= ''.T_('Manage').''; } - if( $current_User->check_perm( 'blog_properties', 'copy', false, $Blog->ID ) ) + if( check_user_perm( 'blog_properties', 'copy', false, $Blog->ID ) ) { // If user can copy collection properties: $r .= action_icon( T_('Duplicate this collection...'), 'copy', $admin_url.'?ctrl=collections&action=copy&blog='.$Blog->ID ); } - if( $current_User->check_perm( 'blog_properties', 'edit', false, $Blog->ID ) ) + if( check_user_perm( 'blog_properties', 'edit', false, $Blog->ID ) ) { // If user can edit collection properties: $r .= action_icon( T_('Delete this blog...'), 'delete', $admin_url.'?ctrl=collections&action=delete&blog='.$Blog->ID.'&'.url_crumb('collection').'&redirect_to='.rawurlencode( regenerate_url( '', '', '', '&' ) ) ); } @@ -3040,19 +3083,19 @@ function blog_row_actions( $Blog, $sec_ID ) */ function blog_row_group_actions( & $row ) { - global $current_User, $admin_url; + global $admin_url; $r = ''; - if( $current_User->check_perm( 'section', 'edit', false, $row->sec_ID ) ) + if( check_user_perm( 'section', 'edit', false, $row->sec_ID ) ) { // If user can edit the section: $r .= action_icon( T_('Edit this section'), 'edit', $admin_url.'?ctrl=collections&action=edit_section&sec_ID='.$row->sec_ID ); } - if( $current_User->check_perm( 'blogs', 'create', false, $row->sec_ID ) ) + if( check_user_perm( 'blogs', 'create', false, $row->sec_ID ) ) { // If user can create new collection in the section: $r .= action_icon( T_('New Collection').'...', 'new', $admin_url.'?ctrl=collections&action=new&sec_ID='.$row->sec_ID ); } - if( $row->sec_ID != 1 && $row->blog_ID === NULL && $current_User->check_perm( 'section', 'edit', false, $row->sec_ID ) ) + if( $row->sec_ID != 1 && $row->blog_ID === NULL && check_user_perm( 'section', 'edit', false, $row->sec_ID ) ) { // If user can delete the section(only without collections): $r .= action_icon( T_('Delete this section!'), 'delete', $admin_url.'?ctrl=collections&action=delete_section&sec_ID='.$row->sec_ID.'&'.url_crumb( 'section' ) ); } @@ -3069,12 +3112,12 @@ function blog_row_group_actions( & $row ) */ function model_row_actions( $Blog ) { - global $current_User, $admin_url; + global $admin_url; $r = ''; $r .= ''.T_('View').''; $r .= ''.T_('Use this model').''; - if( $current_User->check_perm( 'blog_properties', 'edit', false, $Blog->ID ) ) + if( check_user_perm( 'blog_properties', 'edit', false, $Blog->ID ) ) { $r .= action_icon( T_('Edit this collection...'), 'edit', $admin_url.'?ctrl=coll_settings&tab=general&blog='.$Blog->ID ); $r .= action_icon( T_('Delete this blog...'), 'delete', $admin_url.'?ctrl=collections&action=delete&blog='.$Blog->ID.'&'.url_crumb('collection').'&redirect_to='.rawurlencode( regenerate_url( '', '', '', '&' ) ) ); diff --git a/inc/collections/model/_blog_js.funcs.php b/inc/collections/model/_blog_js.funcs.php index 7cd86b22765..594ab957a98 100644 --- a/inc/collections/model/_blog_js.funcs.php +++ b/inc/collections/model/_blog_js.funcs.php @@ -4,7 +4,7 @@ // Require this file because function evoAlert() is used here -require_js( 'functions.js', 'blog', false, true ); +require_js_defer( 'functions.js', 'blog', true ); ?> '; + $raty_params = array( + 'scoreName' => "comment_rating", + 'start' => (int) $this->rating, + 'hintList' => array( + $params['label_low'], + $params['label_2'], + $params['label_3'], + $params['label_4'], + $params['label_high'], + ), + 'width' => 110, + ); - echo $params['after']; + if( is_ajax_request() ) + { + ?> + + is_meta() ) { // Don't touch Item when this Comment is meta @@ -5450,8 +5449,6 @@ function get_allowed_status( $current_status = NULL ) */ function restrict_status( $update_status = false ) { - global $current_User; - // Store current status to display a warning: $current_status = $this->get( 'status' ); @@ -5459,7 +5456,7 @@ function restrict_status( $update_status = false ) if( $this->is_meta() ) { // Internal comment: - if( ! is_logged_in() || ( $commented_Item && ! $current_User->check_perm( 'meta_comment', 'view', false, $commented_Item->get_blog_ID() ) ) ) + if( ! is_logged_in() || ( $commented_Item && ! check_user_perm( 'meta_comment', 'view', false, $commented_Item->get_blog_ID() ) ) ) { // Change internal comment status to 'protected' if user has no perm to view them: $comment_allowed_status = 'protected'; } @@ -5588,13 +5585,17 @@ function render_inline_tags( $content, $params = array() ) { $params = array_merge( array( 'check_code_block' => true, // TRUE to find inline tags only outside of codeblocks - 'render_inline_files' => true, + 'render_tag_image' => true, + 'render_tag_file' => true, + 'render_tag_inline' => true, + 'render_tag_video' => true, + 'render_tag_audio' => true, + 'render_tag_thumbnail' => true, + 'render_tag_folder' => true, ), $params ); - if( $params['render_inline_files'] ) - { // Render inline file tags like [image:123:caption] or [file:123:caption]: - $content = render_inline_files( $content, $this, $params ); - } + // Render inline file tags like [image:123:caption] or [file:123:caption]: + $content = render_inline_files( $content, $this, $params ); return $content; } diff --git a/inc/comments/model/_comment.funcs.php b/inc/comments/model/_comment.funcs.php index db27d778874..09eb4f83a3a 100644 --- a/inc/comments/model/_comment.funcs.php +++ b/inc/comments/model/_comment.funcs.php @@ -246,20 +246,19 @@ function comments_number( $zero='#', $one='#', $more='#', $post_ID = NULL ) */ function get_allowed_statuses( $blog ) { - global $current_User; $statuses = array(); - if( $current_User->check_perm( 'blog_draft_comments', 'edit', false, $blog ) ) + if( check_user_perm( 'blog_draft_comments', 'edit', false, $blog ) ) { $statuses[] = 'draft'; } - if( $current_User->check_perm( 'blog_published_comments', 'edit', false, $blog ) ) + if( check_user_perm( 'blog_published_comments', 'edit', false, $blog ) ) { $statuses[] = 'published'; } - if( $current_User->check_perm( 'blog_deprecated_comments', 'edit', false, $blog ) ) + if( check_user_perm( 'blog_deprecated_comments', 'edit', false, $blog ) ) { $statuses[] = 'deprecated'; } @@ -457,9 +456,7 @@ function add_jsban( $url ) */ function add_ban_icons( $content ) { - global $current_User; - - if( ! $current_User->check_perm( 'spamblacklist', 'edit' ) ) + if( ! check_user_perm( 'spamblacklist', 'edit' ) ) { // Current user has no permission to edit the spam contents return $content; } @@ -581,7 +578,7 @@ function add_ban_icons_callback( $content ) */ function get_opentrash_link( $check_perm = true, $force_show = false, $params = array() ) { - global $admin_url, $current_User, $DB, $blog; + global $admin_url, $DB, $blog; $params = array_merge( array( 'before' => '
    ', @@ -589,7 +586,7 @@ function get_opentrash_link( $check_perm = true, $force_show = false, $params = 'class' => 'action_icon btn btn-default btn-sm', ), $params ); - $show_recycle_bin = ( !$check_perm || $current_User->check_perm( 'blogs', 'editall' ) ); + $show_recycle_bin = ( !$check_perm || check_user_perm( 'blogs', 'editall' ) ); if( $show_recycle_bin && ( !$force_show ) ) { // get number of trash comments: $SQL = new SQL( 'Get number of trash comments for open trash link' ); @@ -630,7 +627,7 @@ function get_opentrash_link( $check_perm = true, $force_show = false, $params = */ function echo_disabled_comments( $allow_comments_value, $item_url, $params = array() ) { - global $Settings, $current_User; + global $Settings; $params = array_merge( array( 'comments_disabled_text_member' => T_( 'You must be a member of this blog to comment.' ), @@ -684,7 +681,7 @@ function echo_disabled_comments( $allow_comments_value, $item_url, $params = arr { // user is not logged in $login_link = ''.T_( 'Log in now!' ).''; } - elseif( $current_User->check_status( 'can_be_validated' ) ) + elseif( check_user_status( 'can_be_validated' ) ) { // logged in but the account is not activated $disabled_text = $params['comments_disabled_text_validated']; $form_disabled_text = $disabled_text; @@ -917,53 +914,20 @@ function echo_comment_reply_js( $Item ) { global $Collection, $Blog; - if( !isset( $Blog ) ) - { + if( ! isset( $Blog ) || ! $Blog->get_setting( 'threaded_comments' ) ) + { // If threaded comments are not enabled for current Collection: return false; } - if( !$Blog->get_setting( 'threaded_comments' ) ) - { - return false; - } - -?> - - $Item->ID, + 'reply_button_msg' => TS_('Reply to this comment'), + 'link_back_url' => url_add_param( $Item->get_permanent_url(), 'reply_ID=\' + comment_ID + \'&redir=no', '&', false ), + 'link_back_specific_comment_msg' => TS_('You are currently replying to a specific comment'), + 'link_back_current_comment_msg' => TS_('You are currently replying to this comment'), + ); + expose_var_to_js( 'evo_init_comment_reply_config', $js_config ); } @@ -998,8 +962,7 @@ function echo_comment_moderate_js() */ function check_comment_mass_delete( $CommentList ) { - global $current_User; - if( !$current_User->check_perm( 'blogs', 'all' ) ) + if( ! check_user_perm( 'blogs', 'all' ) ) { // Check permission return false; } @@ -1202,8 +1165,7 @@ function comments_results_block( $params = array() ) return; } - global $current_User; - if( !$current_User->check_perm( 'users', 'moderate' ) ) + if( ! check_user_perm( 'users', 'moderate' ) ) { // Check minimum permission: return; } @@ -1550,9 +1512,7 @@ function handle_comment_cookies( $set_cookies, $author, $email = '', $url = '', */ function get_type( $Comment ) { - global $current_User; - - if( $Comment->can_be_displayed() || $current_User->check_perm( 'comment!CURSTATUS', 'moderate', false, $Comment ) ) + if( $Comment->can_be_displayed() || check_user_perm( 'comment!CURSTATUS', 'moderate', false, $Comment ) ) { return $Comment->get( 'type' ); } @@ -1571,9 +1531,7 @@ function get_type( $Comment ) */ function get_author( $Comment ) { - global $current_User; - - if( $Comment->can_be_displayed() || $current_User->check_perm( 'comment!CURSTATUS', 'moderate', false, $Comment ) ) + if( $Comment->can_be_displayed() || check_user_perm( 'comment!CURSTATUS', 'moderate', false, $Comment ) ) { $author_User = $Comment->get_author_User(); if( $author_User != NULL ) @@ -1598,9 +1556,7 @@ function get_author( $Comment ) */ function get_url( $Comment ) { - global $current_User; - - if( $current_User->check_perm( 'comment!CURSTATUS', 'moderate', false, $Comment ) ) + if( check_user_perm( 'comment!CURSTATUS', 'moderate', false, $Comment ) ) { return $Comment->author_url_with_actions( NULL, false ); } @@ -1619,9 +1575,7 @@ function get_url( $Comment ) */ function get_author_email( $Comment ) { - global $current_User; - - if( $current_User->check_perm( 'comment!CURSTATUS', 'moderate', false, $Comment ) ) + if( check_user_perm( 'comment!CURSTATUS', 'moderate', false, $Comment ) ) { return $Comment->get_author_email(); } @@ -1640,9 +1594,7 @@ function get_author_email( $Comment ) */ function get_author_ip( $Comment, $param_prefix = '' ) { - global $current_User; - - if( $current_User->check_perm( 'comment!CURSTATUS', 'moderate', false, $Comment ) ) + if( check_user_perm( 'comment!CURSTATUS', 'moderate', false, $Comment ) ) { if( empty( $Comment->author_IP ) ) { @@ -1674,9 +1626,7 @@ function get_author_ip( $Comment, $param_prefix = '' ) */ function get_spam_karma( $Comment ) { - global $current_User; - - if( $current_User->check_perm( 'comment!CURSTATUS', 'moderate', false, $Comment ) ) + if( check_user_perm( 'comment!CURSTATUS', 'moderate', false, $Comment ) ) { return $Comment->get( 'spam_karma' ); } @@ -1726,7 +1676,7 @@ function get_styled_status( $status_value, $status_title, $status_class = '' ) */ function comment_edit_actions( $Comment ) { - global $current_User, $admin_url; + global $admin_url; $r = ''; if( !is_logged_in() ) @@ -1734,8 +1684,8 @@ function comment_edit_actions( $Comment ) return $r; } - $user_has_edit_perm = $current_User->check_perm( 'comment!CURSTATUS', 'edit', false, $Comment ); - $user_has_delete_perm = $current_User->check_perm( 'comment!CURSTATUS', 'delete', false, $Comment ); + $user_has_edit_perm = check_user_perm( 'comment!CURSTATUS', 'edit', false, $Comment ); + $user_has_delete_perm = check_user_perm( 'comment!CURSTATUS', 'delete', false, $Comment ); if( $user_has_edit_perm || $user_has_delete_perm ) { // Display edit and delete button if current user has the rights: diff --git a/inc/comments/model/_comment_js.funcs.php b/inc/comments/model/_comment_js.funcs.php index 5281a7e0c54..7947ab61927 100644 --- a/inc/comments/model/_comment_js.funcs.php +++ b/inc/comments/model/_comment_js.funcs.php @@ -2,684 +2,35 @@ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); -global $Collection, $Blog, $current_User, $Session, $admin_url, $status_list, $CommentList, $b2evo_icons_type; +global $Collection, $Blog, $Session, $admin_url, $status_list, $CommentList, $b2evo_icons_type; // Require this file because function evoAlert() is used here -require_js( 'functions.js', 'blog', false, true ); +require_js_defer( 'functions.js', 'blog', true ); // Initialize JavaScript to build and open window: echo_modalwindow_js(); -?> - - is_admin_page(), + 'admin_url' => $admin_url, + 'crumb_comment' => get_crumb( 'comment' ), + 'crumb_antispam' => get_crumb( 'antispam' ), + 'blog_ID' => $Blog->ID, + 'b2evo_icons_type' => isset( $b2evo_icons_type ) ? $b2evo_icons_type : '', + 'request_from' => request_from(), + 'displayed' => ! empty( $CommentList ) ? intval( $CommentList->result_num_rows ) : 0, + + 'button_class_button_red' => button_class( 'button_red' ), + 'button_class_button_green' => button_class( 'button_green' ), + 'button_class_button' => button_class( 'button', true ), + 'button_class_group' => button_class( 'group', true ), + 'button_class_text' => button_class( 'text', true ), + + 'delete_confirmation_msg' => T_('You are about to delete this comment!\\nThis cannot be undone!'), + 'loading_msg' => T_('Loading...'), + 'confirm_ban_delete_title' => T_('Confirm ban & delete'), + 'perform_selected_operations_msg' => T_('Perform selected operations'), + ); + + expose_var_to_js( 'evo_comment_funcs_config', evo_json_encode( $comment_funcs_config ) ); ?> diff --git a/inc/comments/model/_commentquery.class.php b/inc/comments/model/_commentquery.class.php index 15f7a7693b6..d65379203f3 100644 --- a/inc/comments/model/_commentquery.class.php +++ b/inc/comments/model/_commentquery.class.php @@ -607,7 +607,7 @@ function user_perm_restrict( $user_perm, $blog_ID ) return; } - if( $current_User->check_perm( 'blogs', 'editall' ) ) + if( check_user_perm( 'blogs', 'editall' ) ) { // User has global permission one ach blog return; } diff --git a/inc/comments/views/_browse_comments.view.php b/inc/comments/views/_browse_comments.view.php index 37ae2f3b13c..51de916fd48 100644 --- a/inc/comments/views/_browse_comments.view.php +++ b/inc/comments/views/_browse_comments.view.php @@ -27,7 +27,7 @@ */ global $CommentList; -global $current_User, $admin_url, $tab3; +global $admin_url, $tab3; /* * Display comments: @@ -45,7 +45,7 @@ $block_item_Widget->global_icon( T_('Delete all comments!'), 'recycle', regenerate_url( 'action', 'action=mass_delete' ), T_('Mass delete...'), 3, 3 ); } -if( $tab3 != 'meta' && $current_User->check_perm( 'blogs', 'editall' ) ) +if( $tab3 != 'meta' && check_user_perm( 'blogs', 'editall' ) ) { if( $CommentList->is_trashfilter() ) { diff --git a/inc/comments/views/_comment.form.php b/inc/comments/views/_comment.form.php index 9e775313c19..4f8c9395bd4 100644 --- a/inc/comments/views/_comment.form.php +++ b/inc/comments/views/_comment.form.php @@ -38,7 +38,7 @@ ); $link_attribs = array( 'style' => 'margin-left:1ex', 'class' => 'btn btn-sm btn-default' ); // Avoid misclicks by all means! -if( $current_User->check_perm( 'blog_post!draft', 'edit', false, $Blog->ID ) ) +if( check_user_perm( 'blog_post!draft', 'edit', false, $Blog->ID ) ) { $Form->global_icon( TB_( 'Post as a quote' ), 'elevate', '?ctrl=comments&action=elevate&type=quote&comment_ID='.$edited_Comment->ID.'&'.url_crumb('comment'), TB_( 'Post as a quote' ), 4, 3, $link_attribs, 'elevate' ); @@ -96,7 +96,7 @@ echo '
    '; $Blog_owner_User = & $Blog->get_owner_User(); - if( ( $Blog_owner_User->ID == $current_User->ID ) || $current_User->check_perm( 'blog_admin', 'edit', false, $Blog->ID ) ) + if( ( $Blog_owner_User->ID == $current_User->ID ) || check_user_perm( 'blog_admin', 'edit', false, $Blog->ID ) ) { // User has permission to change comment's post, because user is the owner of the current blog, or user has admin full access permission for current blog $Form->hidden( 'moveto_post', $comment_Item->ID ); } @@ -114,7 +114,7 @@ if( $edited_Comment->get_author_User() ) { // This comment has been created by member - if( $current_User->check_perm( 'users', 'edit' ) ) + if( check_user_perm( 'users', 'edit' ) ) { // Allow to change an author if current user has a permission: $Form->username( 'comment_author_login', $edited_Comment->get_author_User(), TB_('Author'), '' ); } @@ -231,7 +231,7 @@ } // ####################### ADVANCED PROPERTIES ######################### - if( $current_User->check_perm( 'blog_edit_ts', 'edit', false, $Blog->ID ) ) + if( check_user_perm( 'blog_edit_ts', 'edit', false, $Blog->ID ) ) { // ------------------------------------ TIME STAMP ------------------------------------- $Form->begin_fieldset( TB_('Date & Time'), array( 'id' => 'cmntform_datetime', 'fold' => true ) ); diff --git a/inc/comments/views/_comment_list.inc.php b/inc/comments/views/_comment_list.inc.php index 712075d0105..5abb93b0c27 100644 --- a/inc/comments/views/_comment_list.inc.php +++ b/inc/comments/views/_comment_list.inc.php @@ -23,7 +23,7 @@ */ global $CommentList; -global $AdminUI, $UserSettings, $current_User; +global $AdminUI, $UserSettings; // If rediret_to was not set, create new redirect $redirect_to = param( 'redirect_to', 'url', regenerate_url( '', 'filter=restore', '', '&' ) ); @@ -121,11 +121,11 @@ ) ); } - if( ! $comments_can_be_recycled && $Comment->get( 'status' ) != 'trash' && $current_User->check_perm( 'comment!CURSTATUS', 'delete', false, $Comment ) ) + if( ! $comments_can_be_recycled && $Comment->get( 'status' ) != 'trash' && check_user_perm( 'comment!CURSTATUS', 'delete', false, $Comment ) ) { // Set flag to know at least one comment from the current list can be recycled: $comments_can_be_recycled = true; } - if( ! $comments_can_be_deleted && $current_User->check_perm( 'comment!CURSTATUS', 'delete', false, $Comment ) ) + if( ! $comments_can_be_deleted && check_user_perm( 'comment!CURSTATUS', 'delete', false, $Comment ) ) { // Set flag to know at least one comment from the current list can be deleted: $comments_can_be_deleted = true; } @@ -149,7 +149,7 @@ echo_comment_status_buttons( $Form, NULL, $item_status, 'comments_visibility' ); echo_status_dropdown_button_js( 'comment' ); - if( $item_id > 0 && $current_User->check_perm( 'blog_post_statuses', 'edit', false, $blog ) ) + if( $item_id > 0 && check_user_perm( 'blog_post_statuses', 'edit', false, $blog ) ) { // Display a button to create a post from selected comments: echo ' '.T_('or').' '; $Form->button( array( 'submit', 'actionArray[create_comments_post]', T_('Create new Post'), 'btn-warning' ) ); diff --git a/inc/comments/views/_comments_sidebar.view.php b/inc/comments/views/_comments_sidebar.view.php index d05224a40d4..a4a880c6630 100644 --- a/inc/comments/views/_comments_sidebar.view.php +++ b/inc/comments/views/_comments_sidebar.view.php @@ -24,8 +24,6 @@ */ global $Collection, $Blog; -global $current_User; - global $CommentList; $pp = $CommentList->param_prefix; diff --git a/inc/comments/views/_trash_comments.view.php b/inc/comments/views/_trash_comments.view.php index 4491d173ede..734180d3d50 100644 --- a/inc/comments/views/_trash_comments.view.php +++ b/inc/comments/views/_trash_comments.view.php @@ -13,9 +13,7 @@ */ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); -global $current_User; - -$current_User->check_perm( 'blogs', 'editall', true ); +check_user_perm( 'blogs', 'editall', true ); param_action( 'emptytrash', true ); diff --git a/inc/cron/_cron.funcs.php b/inc/cron/_cron.funcs.php index 380993c308c..d90bef74282 100644 --- a/inc/cron/_cron.funcs.php +++ b/inc/cron/_cron.funcs.php @@ -251,7 +251,8 @@ function call_job( $job_key, $job_params = array() ) if( $error_code != 1 ) { // We got an error $result_status = ( $error_code == 20 ? 'imap_error' : 'error' ); - $result_message_text = '[Error code: '.$error_code.']'."\n".$result_message_text; + $result_message_text = 'Error code: '.$error_code."\n" + .'Result message: '.$result_message_text."\n\n"; if( is_array( $result_message ) ) { // If result is array $result_message['message'] = $result_message_text; diff --git a/inc/cron/cronjobs.ctrl.php b/inc/cron/cronjobs.ctrl.php index cfe0e732708..9af6e2fbc5b 100644 --- a/inc/cron/cronjobs.ctrl.php +++ b/inc/cron/cronjobs.ctrl.php @@ -16,8 +16,8 @@ load_funcs( 'cron/_cron.funcs.php' ); // Check minimum permission: -$current_User->check_perm( 'admin', 'normal', true ); -$current_User->check_perm( 'options', 'view', true ); +check_user_perm( 'admin', 'normal', true ); +check_user_perm( 'options', 'view', true ); $AdminUI->set_path( 'options', 'cron', 'list' ); @@ -40,7 +40,7 @@ { case 'new': // Check that we have permission to edit options: - $current_User->check_perm( 'options', 'edit', true, NULL ); + check_user_perm( 'options', 'edit', true, NULL ); load_class( 'cron/model/_cronjob.class.php', 'Cronjob' ); $edited_Cronjob = new Cronjob(); @@ -52,7 +52,7 @@ case 'edit': case 'copy': // Check that we have permission to edit options: - $current_User->check_perm( 'options', 'edit', true, NULL ); + check_user_perm( 'options', 'edit', true, NULL ); if( ( $action == 'edit' && $edited_Cronjob->get_status() != 'pending' ) || ( $action == 'copy' && $edited_Cronjob->get_status() != 'error' ) ) @@ -74,7 +74,7 @@ $Session->assert_received_crumb( 'crontask' ); // Check that we have permission to edit options: - $current_User->check_perm( 'options', 'edit', true, NULL ); + check_user_perm( 'options', 'edit', true, NULL ); if( !empty( $edited_Cronjob ) ) { // It is a copy action, we should save the fields "key" & "params" @@ -115,7 +115,7 @@ $Session->assert_received_crumb( 'crontask' ); // Check that we have permission to edit options: - $current_User->check_perm( 'options', 'edit', true, NULL ); + check_user_perm( 'options', 'edit', true, NULL ); if( $edited_Cronjob->load_from_Request() ) { // We could load data from form without errors: @@ -144,7 +144,7 @@ param( 'ctsk_ID', 'integer', true ); // Check that we have permission to edit options: - $current_User->check_perm( 'options', 'edit', true, NULL ); + check_user_perm( 'options', 'edit', true, NULL ); // TODO: prevent deletion of running tasks. $DB->begin(); @@ -190,7 +190,7 @@ $Session->assert_received_crumb( 'cronsettings' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); $cron_jobs = get_cron_jobs_config( 'name' ); foreach( $cron_jobs as $cron_job_key => $cron_job_name ) @@ -217,7 +217,7 @@ { case 'send-email-campaign': // Send a chunk of x emails for the campaign: - if( $current_User->check_perm( 'emails', 'edit' ) ) + if( check_user_perm( 'emails', 'edit' ) ) { // Allow to edit email cron setting "Chunk Size" only if user has a permission: $Settings->set( 'email_campaign_chunk_size', param( 'email_campaign_chunk_size', 'integer', 0 ) ); } diff --git a/inc/cron/jobs/_prune_hits_sessions.job.php b/inc/cron/jobs/_prune_hits_sessions.job.php index a6b1dceab6d..8fa21a6a72a 100644 --- a/inc/cron/jobs/_prune_hits_sessions.job.php +++ b/inc/cron/jobs/_prune_hits_sessions.job.php @@ -8,12 +8,6 @@ global $Settings, $DB; -// Print all unknown errors on screen and save error message -ob_start(); -$DB->save_error_state(); -$DB->show_errors = true; -$DB->halt_on_error = false; - if( $Settings->get( 'auto_prune_stats_mode' ) != 'cron' ) { // Autopruning is NOT requested cron_log_append( T_('Auto pruning is not set to run as a scheduled task') ); @@ -22,37 +16,39 @@ load_class( 'sessions/model/_hitlist.class.php', 'Hitlist' ); -$result = Hitlist::dbprune( 'cron_job' ); // will prune once per day, according to Settings +// Print all unknown errors on screen and save error message +ob_start(); +$DB->save_error_state(); +$DB->show_errors = true; +$DB->halt_on_error = false; + +$result = Hitlist::dbprune( 'cron_job', true ); // will prune once per day, according to Settings // Restore DB error states $DB->restore_error_state(); // Get the unknown errors from screen -$unknown_errors = ob_get_clean(); +$unknown_errors = trim( ob_get_clean() ); + +// Make sure we have a result message: +$result_message = array( 'message' => 'Result Message:'."\n\n".(isset( $result['message'] ) ? $result['message'] : '' ) ); + +$result_message['message'] .= "\nResult so far:".(isset( $result['result'] ) ? "'".$result['result']."'" : '[Not set]' ); if( ! empty( $unknown_errors ) ) { // Some errors were created, probably DB errors - if( ! is_array( $result ) ) - { // Set result to array format - $result = array(); - } - // This result must have an error status - $result['result'] = 'error'; // Append the unknown error from screen to already generated message - $result['message'] = ( isset( $result['message'] ) ? $result['message'] : '' ) - ."\n".$unknown_errors; + $result_message['message'] .= "\n\n".'Unknown errors: "'.$unknown_errors.'"'; + return 100; // error } - -if( empty( $result ) ) +else { - return 1; /* ok */ + $result_message['message'] .= "\n\nNo unknown errors"; } -elseif( isset( $result['message'] ) ) -{ // Get a message from result for report - if( isset( $result['result'] ) && $result['result'] == 'ok' ) - { - return 1; /* ok */ - } + +if( isset( $result['result'] ) && $result['result'] == 'ok' ) +{ + return 1; // ok } -return 100; +return 100; // error ?> \ No newline at end of file diff --git a/inc/cron/views/_cronjob.view.php b/inc/cron/views/_cronjob.view.php index 3c8fc56a8a1..6320fd839d4 100644 --- a/inc/cron/views/_cronjob.view.php +++ b/inc/cron/views/_cronjob.view.php @@ -15,11 +15,11 @@ load_class( '_core/ui/_table.class.php', 'Table' ); -global $cjob_row, $current_User, $admin_url; +global $cjob_row, $admin_url; $Form = new Form( NULL, 'cronlog' ); -if( empty( $cjob_row->clog_status ) && $current_User->check_perm( 'options', 'edit', false, NULL ) ) +if( empty( $cjob_row->clog_status ) && check_user_perm( 'options', 'edit', false, NULL ) ) { // User can edit this job: $Form->global_icon( T_('Edit this job'), 'edit', $admin_url.'?ctrl=crontab&action=edit&ctsk_ID='.$cjob_row->ctsk_ID, T_('Edit this job').'...', 3, 3 ); } diff --git a/inc/cron/views/_cronjob_list.view.php b/inc/cron/views/_cronjob_list.view.php index 85baf8ea043..4e569eb605e 100644 --- a/inc/cron/views/_cronjob_list.view.php +++ b/inc/cron/views/_cronjob_list.view.php @@ -170,7 +170,7 @@ $Results->global_icon( T_('Refresh'), 'refresh', regenerate_url(), T_('Refresh'), 3, 4 ); -if( $current_User->check_perm( 'options', 'edit', false, NULL ) ) +if( check_user_perm( 'options', 'edit', false, NULL ) ) { // Permission to edit settings: $Results->global_icon( T_('Create a new scheduled job...'), 'new', regenerate_url( 'action,cjob_ID', 'action=new' ), T_('New job').' »', 3, 4, array( 'class' => 'action_icon btn-primary' ) ); } @@ -318,11 +318,11 @@ function crontab_repeat( $ctsk_repeat_after, $ctsk_repeat_variation, $ctsk_key ) function crontab_actions( $ctsk_ID, $status ) { - global $current_User, $admin_url; + global $admin_url; $col = ''; - if( $current_User->check_perm( 'options', 'edit', false, NULL ) ) + if( check_user_perm( 'options', 'edit', false, NULL ) ) { // User can edit options: if( $status == 'pending' ) { // Icon for edit action diff --git a/inc/cron/views/_cronjob_settings.form.php b/inc/cron/views/_cronjob_settings.form.php index 8d25b92cb6f..f54f2565984 100644 --- a/inc/cron/views/_cronjob_settings.form.php +++ b/inc/cron/views/_cronjob_settings.form.php @@ -14,7 +14,7 @@ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); -global $Settings, $current_User, $admin_url; +global $Settings, $admin_url; $Form = new Form( NULL, 'cron_settings_checkchanges' ); @@ -35,21 +35,21 @@ { case 'send-email-campaign': // Send a chunk of x emails for the campaign: - if( $current_User->check_perm( 'emails', 'edit' ) ) + if( check_user_perm( 'emails', 'edit' ) ) { // Allow to edit email cron settings only if user has a permission: $Form->text_input( 'email_campaign_chunk_size', $Settings->get( 'email_campaign_chunk_size' ), 5, TB_('Chunk Size'), TB_('emails at a time'), array( 'maxlength' => 10 ) ); } - elseif( $current_User->check_perm( 'emails', 'view' ) ) + elseif( check_user_perm( 'emails', 'view' ) ) { // Only display setting value: $Form->info( TB_('Chunk Size'), $Settings->get( 'email_campaign_chunk_size' ), TB_('emails at a time') ); } $Form->duration_input( 'email_campaign_cron_repeat', $Settings->get( 'email_campaign_cron_repeat' ), TB_('Delay between chunks'), 'days', 'minutes', array( 'note' => TB_('timing between scheduled job runs') ) ); $Form->duration_input( 'email_campaign_cron_limited', $Settings->get( 'email_campaign_cron_limited' ), TB_('Delay in case all remaining recipients have reached max # of emails for the current day'), 'days', 'minutes', array( 'note' => TB_('timing between scheduled job runs') ) ); - if( $current_User->check_perm( 'emails', 'edit' ) ) + if( check_user_perm( 'emails', 'edit' ) ) { // Allow to edit email cron settings only if user has a permission: $Form->text_input( 'email_campaign_max_domain', $Settings->get( 'email_campaign_max_domain' ), 5, TB_('Max emails to same domain'), TB_('In each chunk, avoid sending too many emails to same recipient domain (Useful to avoid balcklisting from gmail.com, hotmail.com, etc.)'), array( 'maxlength' => 10 ) ); } - elseif( $current_User->check_perm( 'emails', 'view' ) ) + elseif( check_user_perm( 'emails', 'view' ) ) { // Only display setting value: $Form->info( TB_('Max emails to same domain'), $Settings->get( 'email_campaign_max_domain' ) ); } @@ -186,7 +186,7 @@ } $buttons = array(); -if( $current_User->check_perm( 'options', 'edit' ) ) +if( check_user_perm( 'options', 'edit' ) ) { // Allow to save cron settings only if user has a permission: $buttons[] = array( 'submit', '', TB_('Save Changes!'), 'SaveButton' ); } diff --git a/inc/customize/views/_other.view.php b/inc/customize/views/_other.view.php index 690a5d66795..8477d2cff66 100644 --- a/inc/customize/views/_other.view.php +++ b/inc/customize/views/_other.view.php @@ -16,7 +16,7 @@ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); -global $AdminUI, $Settings, $current_User, $admin_url; +global $AdminUI, $Settings; // Display customizer tabs to switch between site/collection skins and widgets in special div on customizer mode: $AdminUI->display_customizer_tabs( array( @@ -26,7 +26,7 @@ echo '
    '; // Check if current User can edit site options: -$can_edit_site_options = ( $Settings->get( 'site_skins_enabled' ) && $current_User->check_perm( 'options', 'edit' ) ); +$can_edit_site_options = ( $Settings->get( 'site_skins_enabled' ) && check_user_perm( 'options', 'edit' ) ); if( $can_edit_site_options ) { // Start of list of sites: diff --git a/inc/dashboard/dashboard.ctrl.php b/inc/dashboard/dashboard.ctrl.php index 0abe76d1537..da599269e13 100644 --- a/inc/dashboard/dashboard.ctrl.php +++ b/inc/dashboard/dashboard.ctrl.php @@ -46,7 +46,7 @@ $AdminUI->set_page_manual_link( 'site-dashboard' ); // Load jquery UI to animate background color on change comment status and to transfer a comment to recycle bin -require_js( '#jqueryUI#' ); +require_js_defer( '#jqueryUI#' ); // Load the appropriate blog navigation styles (including calendar, comment forms...): require_css( $AdminUI->get_template( 'blog_base.css' ) ); // Default styles for the blog navigation @@ -54,8 +54,8 @@ require_js_helper( 'colorbox' ); // Include files to work with charts -require_js( '#easypiechart#' ); -require_css( 'jquery/jquery.easy-pie-chart.css' ); +require_js_defer( '#easypiechart#' ); +require_css( 'ext:jquery/easy-pie-chart/css/jquery.easy-pie-chart.css' ); // Init JS to autcomplete the user logins init_autocomplete_login_js( 'rsc_url', $AdminUI->get_template( 'autocomplete_plugin' ) ); @@ -70,7 +70,7 @@ $AdminUI->disp_payload_begin(); $collection_count = get_table_count( 'T_blogs' ); -if( $current_User->check_perm( 'blogs', 'create' ) && $collection_count === 0 ) +if( check_user_perm( 'blogs', 'create' ) && $collection_count === 0 ) { // Display welcome panel: $AdminUI->disp_view( 'collections/views/_welcome_demo_content.view.php' ); @@ -82,7 +82,7 @@ * Administrative tasks */ -if( $current_User->check_perm( 'options', 'edit' ) ) +if( check_user_perm( 'options', 'edit' ) ) { // We have some serious admin privilege: /** * @var AbstractSettings diff --git a/inc/dashboard/model/_dashboard.funcs.php b/inc/dashboard/model/_dashboard.funcs.php index c39437542f9..fd71f9d45ca 100644 --- a/inc/dashboard/model/_dashboard.funcs.php +++ b/inc/dashboard/model/_dashboard.funcs.php @@ -359,7 +359,7 @@ function show_comments_awaiting_moderation( $blog_ID, $CommentList = NULL, $limi $Comment->spam_karma( ' • '.T_('Spam Karma').': %s%', ' • '.T_('No Spam Karma') ); echo '
    '; - $user_permission = $current_User->check_perm( 'meta_comment', 'edit', false, $Comment ); + $user_permission = check_user_perm( 'meta_comment', 'edit', false, $Comment ); if( $user_permission ) { // Put the internal comment content into this container to edit by ajax: echo '
    '; diff --git a/inc/email_campaigns/campaigns.ctrl.php b/inc/email_campaigns/campaigns.ctrl.php index 2fc44f9bd3f..9bb07ef2259 100644 --- a/inc/email_campaigns/campaigns.ctrl.php +++ b/inc/email_campaigns/campaigns.ctrl.php @@ -15,8 +15,8 @@ // Check permission: -$current_User->check_perm( 'admin', 'normal', true ); -$current_User->check_perm( 'emails', 'view', true ); +check_user_perm( 'admin', 'normal', true ); +check_user_perm( 'emails', 'view', true ); load_class( 'email_campaigns/model/_emailcampaign.class.php', 'EmailCampaign' ); load_funcs( 'email_campaigns/model/_emailcampaign.funcs.php' ); @@ -50,7 +50,7 @@ // New Email Campaign form: // Check permission: - $current_User->check_perm( 'emails', 'edit', true ); + check_user_perm( 'emails', 'edit', true ); // Check if at least one newsletter is active: $NewsletterCache = & get_NewsletterCache(); @@ -72,7 +72,7 @@ $Session->assert_received_crumb( 'campaign' ); // Check permission: - $current_User->check_perm( 'emails', 'edit', true ); + check_user_perm( 'emails', 'edit', true ); $new_EmailCampaign = new EmailCampaign(); @@ -101,7 +101,7 @@ $Session->assert_received_crumb( 'campaign' ); // Check permission: - $current_User->check_perm( 'emails', 'edit', true ); + check_user_perm( 'emails', 'edit', true ); $current_tab = param( 'current_tab', 'string', 'info' ); @@ -150,7 +150,7 @@ $Session->assert_received_crumb( 'campaign' ); // Check permission: - $current_User->check_perm( 'emails', 'edit', true ); + check_user_perm( 'emails', 'edit', true ); // Update the plain-text message field from HTML message: $edited_EmailCampaign->update_plaintext( true ); @@ -173,7 +173,7 @@ $Session->assert_received_crumb( 'campaign' ); // Check permission: - $current_User->check_perm( 'emails', 'edit', true ); + check_user_perm( 'emails', 'edit', true ); $current_tab = param( 'current_tab', 'string', 'info' ); @@ -195,21 +195,6 @@ // We have EXITed already at this point!! break; - case 'hide_wysiwyg_warning': - case 'show_wysiwyg_warning': - global $UserSettings; - - // Show/hide warning when switching from markup to WYSIWYG - $Session->assert_received_crumb( 'campaign' ); - - // Check that this action request is not a CSRF hacked request: - $UserSettings->set( 'show_wysiwyg_warning_emailcampaign', ( $action == 'show_wysiwyg_warning' ? 1: 0 ) ); - $UserSettings->dbupdate(); - - // REDIRECT / EXIT - header_redirect( $admin_url.'?ctrl=campaigns&action=edit&ecmp_ID='.$edited_EmailCampaign->ID.'&tab=compose' ); - break; - case 'create_for_users': case 'update_users': // Select new users for campaigns, Go from controller 'users' @@ -218,7 +203,7 @@ $Session->assert_received_crumb( 'campaign' ); // Check permission: - $current_User->check_perm( 'emails', 'edit', true ); + check_user_perm( 'emails', 'edit', true ); $newsletter_ID = param( 'newsletter', 'integer', 0 ); $NewsletterCache = & get_NewsletterCache(); @@ -276,7 +261,7 @@ $Session->assert_received_crumb( 'campaign' ); // Check permission: - $current_User->check_perm( 'emails', 'edit', true ); + check_user_perm( 'emails', 'edit', true ); if( $edited_EmailCampaign && $edited_EmailCampaign->duplicate() ) { @@ -293,7 +278,7 @@ $Session->assert_received_crumb( 'campaign' ); // Check permission: - $current_User->check_perm( 'emails', 'edit', true ); + check_user_perm( 'emails', 'edit', true ); param( 'from', 'string', '' ); @@ -341,7 +326,7 @@ $Session->assert_received_crumb( 'campaign' ); // Check permission: - $current_User->check_perm( 'emails', 'edit', true ); + check_user_perm( 'emails', 'edit', true ); param( 'from', 'string', '' ); @@ -379,7 +364,7 @@ $Session->assert_received_crumb( 'campaign' ); // Check permission: - $current_User->check_perm( 'emails', 'edit', true ); + check_user_perm( 'emails', 'edit', true ); // Make sure we got an ecmp_ID: param( 'ecmp_ID', 'integer', true ); @@ -416,7 +401,7 @@ $Session->assert_received_crumb( 'campaign' ); // Check permission: - $current_User->check_perm( 'emails', 'edit', true ); + check_user_perm( 'emails', 'edit', true ); // Test email address param( 'test_email_address', 'string', '' ); @@ -466,7 +451,7 @@ $Session->assert_received_crumb( 'campaign' ); // Check permission: - $current_User->check_perm( 'emails', 'edit', true ); + check_user_perm( 'emails', 'edit', true ); // Check campaign before sending $edited_EmailCampaign->check(); @@ -509,7 +494,7 @@ break; } - if( ! $current_User->check_perm( 'options', 'view' ) ) + if( ! check_user_perm( 'options', 'view' ) ) { // No access to view cron jobs: $Messages->add( TB_('Sorry, you don\'t have permission to view scheduled jobs.' ), 'warning' ); $action = 'edit'; @@ -557,7 +542,7 @@ $Session->assert_received_crumb( 'campaigns_plugins' ); // Check permission: - $current_User->check_perm( 'emails', 'edit', true ); + check_user_perm( 'emails', 'edit', true ); load_funcs( 'plugins/_plugin.funcs.php' ); @@ -659,8 +644,6 @@ $AdminUI->set_page_manual_link( 'campaign-compose-panel' ); // Require colorbox js: require_js_helper( 'colorbox' ); - // Init JS to quick upload several files: - init_fileuploader_js(); break; case 'plaintext': $AdminUI->set_page_manual_link( 'campaign-plaintext-panel' ); diff --git a/inc/email_campaigns/model/_emailcampaign.class.php b/inc/email_campaigns/model/_emailcampaign.class.php index 0c5222313d8..94d7523c895 100644 --- a/inc/email_campaigns/model/_emailcampaign.class.php +++ b/inc/email_campaigns/model/_emailcampaign.class.php @@ -1034,8 +1034,6 @@ function send_email( $user_ID, $email_address = '', $mode = '', $update_sent_ts if( $mode == 'test' ) { // Send a test newsletter - global $current_User; - $newsletter_params['boundary'] = 'b2evo-'.md5( rand() ); $headers = array( 'Content-Type' => 'multipart/mixed; boundary="'.$newsletter_params['boundary'].'"' ); @@ -1512,11 +1510,11 @@ function & get_Cronjob( $exclude_error = true ) */ function create_cron_job( $next_chunk = false ) { - global $Messages, $servertimenow, $current_User; + global $Messages, $servertimenow; if( ! $next_chunk && ( $email_campaign_Cronjob = & $this->get_Cronjob() ) ) { // If we create first cron job but this email campaign already has one: - if( $current_User->check_perm( 'options', 'view' ) ) + if( check_user_perm( 'options', 'view' ) ) { // If user has an access to view cron jobs: global $admin_url; $Messages->add( sprintf( T_('A scheduled job was already created for this campaign, click here to view it.'), @@ -1735,6 +1733,20 @@ function add_user_to_automation( $click_type, $user_ID ) return empty( $added_users_num ) ? false : $added_users_num; } + + + /** + * Get creation time of Email Campaign + * + * @param string date/time format: leave empty to use locale default date format + * @param boolean true if you want GMT + */ + function get_creation_time( $format = '', $useGM = false ) + { + $format = locale_resolve_datetime_fmt( $format ); + + return mysql2date( $format, $this->date_ts, $useGM ); + } } -?> \ No newline at end of file +?> diff --git a/inc/email_campaigns/model/_emailcampaign.funcs.php b/inc/email_campaigns/model/_emailcampaign.funcs.php index 058d37460b5..d1511525390 100644 --- a/inc/email_campaigns/model/_emailcampaign.funcs.php +++ b/inc/email_campaigns/model/_emailcampaign.funcs.php @@ -40,7 +40,7 @@ function get_filterset_user_IDs( $filterset_name = 'admin' ) */ function get_campaign_edit_modes( $campaign_ID, $glue = '&' ) { - global $admin_url, $current_User; + global $admin_url; $EmailCampaignCache = & get_EmailCampaignCache(); $EmailCampaign = & $EmailCampaignCache->get_by_ID( $campaign_ID ); @@ -54,7 +54,7 @@ function get_campaign_edit_modes( $campaign_ID, $glue = '&' ) 'text' => T_('Campaign info'), 'href' => $url ); - if( $current_User->check_perm( 'emails', 'edit' ) ) + if( check_user_perm( 'emails', 'edit' ) ) { // User must has a permission to edit emails $modes['info']['onclick'] = "return b2edit_reload( '#campaign_form', '$url', 'undefined', {tab:'info'} );"; } @@ -64,7 +64,7 @@ function get_campaign_edit_modes( $campaign_ID, $glue = '&' ) 'text' => T_('Compose'), 'href' => $url ); - if( $current_User->check_perm( 'emails', 'edit' ) ) + if( check_user_perm( 'emails', 'edit' ) ) { // User must has a permission to edit emails $modes['compose']['onclick'] = "return b2edit_reload( '#campaign_form', '$url', 'undefined', {tab:'compose'} );"; } @@ -75,7 +75,7 @@ function get_campaign_edit_modes( $campaign_ID, $glue = '&' ) 'href' => $url, 'class' => 'ecmp_plaintext_tab'.( $EmailCampaign->get( 'sync_plaintext' ) ? ' hidden' : '' ), ); - if( $current_User->check_perm( 'emails', 'edit' ) ) + if( check_user_perm( 'emails', 'edit' ) ) { // User must has a permission to edit emails $modes['plaintext']['onclick'] = "return b2edit_reload( '#campaign_form', '$url', 'undefined', {tab:'plaintext'} );"; } @@ -85,7 +85,7 @@ function get_campaign_edit_modes( $campaign_ID, $glue = '&' ) 'text' => T_('Review and send'), 'href' => $url ); - if( $current_User->check_perm( 'emails', 'edit' ) ) + if( check_user_perm( 'emails', 'edit' ) ) { // User must has a permission to edit emails $modes['send']['onclick'] = "return b2edit_reload( '#campaign_form', '$url', 'undefined', {tab:'send'} );"; } @@ -95,7 +95,7 @@ function get_campaign_edit_modes( $campaign_ID, $glue = '&' ) 'text' => T_('Recipient list'), 'href' => $url ); - if( $current_User->check_perm( 'emails', 'edit' ) ) + if( check_user_perm( 'emails', 'edit' ) ) { // User must has a permission to edit emails $modes['recipient']['onclick'] = "return b2edit_reload( '#campaign_form', '$url', 'undefined', {tab:'recipient'} );"; } @@ -105,7 +105,7 @@ function get_campaign_edit_modes( $campaign_ID, $glue = '&' ) 'text' => T_('Plugins'), 'href' => $url ); - if( $current_User->check_perm( 'emails', 'edit' ) ) + if( check_user_perm( 'emails', 'edit' ) ) { // User must has a permission to edit emails $modes['plugins']['onclick'] = "return b2edit_reload( '#campaign_form', '$url', 'undefined', {tab:'plugins'} );"; } @@ -338,7 +338,7 @@ function filter_campaign_results_block( & $Form ) */ function campaign_results_block( $params = array() ) { - global $admin_url, $UserSettings, $current_User, $DB; + global $admin_url, $UserSettings, $DB; $params = array_merge( array( 'enlt_ID' => NULL, @@ -387,7 +387,7 @@ function campaign_results_block( $params = array() ) $Results->Cache = & get_EmailCampaignCache(); $Results->title = $params['results_title']; - if( $current_User->check_perm( 'emails', 'edit' ) && $params['display_create_button'] ) + if( check_user_perm( 'emails', 'edit' ) && $params['display_create_button'] ) { // User must has a permission to edit emails $Results->global_icon( T_('Create new campaign').'...', 'new', $admin_url.'?ctrl=campaigns&action=new'.( isset( $params['enlt_ID'] ) ? '&enlt_ID='.$params['enlt_ID'] : '' ), T_('Create new campaign').' »', 3, 4, array( 'class' => 'action_icon btn-primary' ) ); } @@ -558,7 +558,7 @@ function campaign_results_block( $params = array() ) 'th_class' => 'shrinkwrap', 'td_class' => 'shrinkwrap', 'td' => action_icon( T_('Edit this email campaign...'), 'properties', $admin_url.'?ctrl=campaigns&action=edit&ecmp_ID=$ecmp_ID$' ) - .( $current_User->check_perm( 'emails', 'edit' ) ? + .( check_user_perm( 'emails', 'edit' ) ? // Display an action icon to delete newsletter if current User has a perm: action_icon( T_('Duplicate this email campaign...'), 'copy', $admin_url.'?ctrl=campaigns&action=copy&ecmp_ID=$ecmp_ID$' ) .action_icon( T_('Delete this email campaign!'), 'delete', $admin_url.'?ctrl=campaigns&action=delete&ecmp_ID=$ecmp_ID$&'.url_crumb( 'campaign' ) ) : '' ) @@ -579,8 +579,6 @@ function campaign_results_block( $params = array() ) */ function campaign_td_welcome( $ecmp_ID, $ecmp_welcome, $ecmp_activate ) { - global $current_User; - if( $ecmp_welcome ) { // If email campaign is used as welcome message: $welcome_icon = get_icon( 'bullet_green', 'imgtag', array( 'title' => T_('The email campaign is used as "Welcome" for its list.') ) ); @@ -600,7 +598,7 @@ function campaign_td_welcome( $ecmp_ID, $ecmp_welcome, $ecmp_activate ) $activate_icon = ''; } - if( $current_User->check_perm( 'emails', 'edit' ) ) + if( check_user_perm( 'emails', 'edit' ) ) { // Make icon(s) toggle welcome/activate statuses if current User has a perm to edit this: global $admin_url, $ctrl; $icon_url = $admin_url.'?ctrl=campaigns' diff --git a/inc/email_campaigns/newsletters.ctrl.php b/inc/email_campaigns/newsletters.ctrl.php index 565b2d8c37a..3a502d1002b 100644 --- a/inc/email_campaigns/newsletters.ctrl.php +++ b/inc/email_campaigns/newsletters.ctrl.php @@ -21,7 +21,7 @@ $AdminUI->set_path( 'email', 'newletters' ); // Check permission: -$current_User->check_perm( 'emails', 'view', true ); +check_user_perm( 'emails', 'view', true ); load_class( 'email_campaigns/model/_newsletter.class.php', 'Newsletter' ); load_funcs( 'email_campaigns/model/_emailcampaign.funcs.php' ); @@ -32,7 +32,7 @@ if( $tab == 'automations' ) { // Check other permission for automations: - $current_User->check_perm( 'options', 'view', true ); + check_user_perm( 'options', 'view', true ); } if( param( 'enlt_ID', 'integer', '', true ) ) @@ -53,7 +53,7 @@ // New Newsletter: // Check permission: - $current_User->check_perm( 'emails', 'edit', true ); + check_user_perm( 'emails', 'edit', true ); $edited_Newsletter = new Newsletter(); break; @@ -66,7 +66,7 @@ $Session->assert_received_crumb( 'newsletter' ); // Check permission: - $current_User->check_perm( 'emails', 'edit', true ); + check_user_perm( 'emails', 'edit', true ); // Load data from request: if( $edited_Newsletter->load_from_Request() ) @@ -91,7 +91,7 @@ $Session->assert_received_crumb( 'newsletter' ); // Check permission: - $current_User->check_perm( 'emails', 'edit', true ); + check_user_perm( 'emails', 'edit', true ); // Make sure we got an enlt_ID: param( 'enlt_ID', 'integer', true ); @@ -119,7 +119,7 @@ $Session->assert_received_crumb( 'newsletter' ); // Check permission: - $current_User->check_perm( 'emails', 'edit', true ); + check_user_perm( 'emails', 'edit', true ); // Make sure we got an enlt_ID: param( 'enlt_ID', 'integer', true ); @@ -152,7 +152,7 @@ $Session->assert_received_crumb( 'newsletter' ); // Check permission: - $current_User->check_perm( 'emails', 'edit', true ); + check_user_perm( 'emails', 'edit', true ); // Make sure we got an enlt_ID: param( 'enlt_ID', 'integer', true ); @@ -177,7 +177,7 @@ $Session->assert_received_crumb( 'newsletter' ); // Check permission: - $current_User->check_perm( 'emails', 'edit', true ); + check_user_perm( 'emails', 'edit', true ); // Make sure we got an enlt_ID: param( 'enlt_ID', 'integer', true ); @@ -258,7 +258,7 @@ 'text' => TB_('Subscribers'), 'href' => $admin_url.'?ctrl=newsletters&action=edit&tab=subscribers&enlt_ID='.$edited_Newsletter->ID ) ) ); - if( $current_User->check_perm( 'options', 'view' ) ) + if( check_user_perm( 'options', 'view' ) ) { // If current user has a permissions to view options: $AdminUI->add_menu_entries( array( 'email', 'newsletters' ), array( 'automations' => array( diff --git a/inc/email_campaigns/views/_campaigns_compose.form.php b/inc/email_campaigns/views/_campaigns_compose.form.php index 3b471896e51..77139c32b13 100644 --- a/inc/email_campaigns/views/_campaigns_compose.form.php +++ b/inc/email_campaigns/views/_campaigns_compose.form.php @@ -83,7 +83,7 @@ $buttons = array(); -if( $current_User->check_perm( 'emails', 'edit' ) ) +if( check_user_perm( 'emails', 'edit' ) ) { // User must has a permission to edit emails $buttons[] = array( 'submit', 'actionArray[save]', TB_('Save & continue').' >>', 'SaveButton' ); } diff --git a/inc/email_campaigns/views/_campaigns_info.form.php b/inc/email_campaigns/views/_campaigns_info.form.php index a169721e1dd..e101554b22c 100644 --- a/inc/email_campaigns/views/_campaigns_info.form.php +++ b/inc/email_campaigns/views/_campaigns_info.form.php @@ -19,7 +19,7 @@ $Form = new Form( NULL, 'campaign_form' ); $Form->begin_form( 'fform' ); -if( $current_User->check_perm( 'emails', 'edit' ) ) +if( check_user_perm( 'emails', 'edit' ) ) { // Print out this fake button on top in order to use submit action "save" on press "Enter" key: echo ''; } @@ -139,7 +139,7 @@ function update_campaign_recipients_count( ecmp_ID ) $Form->end_fieldset(); $buttons = array(); -if( $current_User->check_perm( 'emails', 'edit' ) ) +if( check_user_perm( 'emails', 'edit' ) ) { // User must has a permission to edit emails $buttons[] = array( 'submit', 'actionArray[save]', TB_('Save info'), 'SaveButton' ); } diff --git a/inc/email_campaigns/views/_campaigns_plaintext.form.php b/inc/email_campaigns/views/_campaigns_plaintext.form.php index ca2e4dc2032..69a8795fa57 100644 --- a/inc/email_campaigns/views/_campaigns_plaintext.form.php +++ b/inc/email_campaigns/views/_campaigns_plaintext.form.php @@ -34,7 +34,7 @@ $Form->end_fieldset(); $buttons = array(); -if( $current_User->check_perm( 'emails', 'edit' ) ) +if( check_user_perm( 'emails', 'edit' ) ) { // User must has a permission to edit emails: $buttons[] = array( 'submit', 'actionArray[save]', TB_('Save & continue').' >>', 'SaveButton' ); $buttons[] = array( 'submit', 'actionArray[resync]', TB_('Resync from HTML'), 'SaveButton btn-info', 'return confirm( \''.TS_('WARNING: if you continue, all manual edits you made to the plain-text version will be lost.').'\' )' ); diff --git a/inc/email_campaigns/views/_campaigns_plugins.form.php b/inc/email_campaigns/views/_campaigns_plugins.form.php index 122203434bb..428c14f5396 100644 --- a/inc/email_campaigns/views/_campaigns_plugins.form.php +++ b/inc/email_campaigns/views/_campaigns_plugins.form.php @@ -68,7 +68,7 @@ //$Form->end_fieldset(); } -if( $current_User->check_perm( 'emails', 'edit' ) ) +if( check_user_perm( 'emails', 'edit' ) ) { $Form->buttons( array( array( 'submit', 'submit', TB_('Save Changes!'), 'SaveButton' ) ) ); } diff --git a/inc/email_campaigns/views/_campaigns_send.form.php b/inc/email_campaigns/views/_campaigns_send.form.php index 5fd5fc2bd70..ffa1d8c4e37 100644 --- a/inc/email_campaigns/views/_campaigns_send.form.php +++ b/inc/email_campaigns/views/_campaigns_send.form.php @@ -23,7 +23,7 @@ $Form = new Form( NULL, 'campaign_form' ); $Form->begin_form( 'fform' ); -if( $current_User->check_perm( 'emails', 'edit' ) ) +if( check_user_perm( 'emails', 'edit' ) ) { // Print out this fake button on top in order to use submit action "test" on press "Enter" key: echo ''; } @@ -121,7 +121,7 @@ $Form->end_fieldset(); $buttons = array(); -if( $current_User->check_perm( 'emails', 'edit' ) ) +if( check_user_perm( 'emails', 'edit' ) ) { // User must has a permission to edit emails $Form->begin_fieldset( TB_('Send test email').get_manual_link( 'campaign-send-test-panel' ) ); diff --git a/inc/email_campaigns/views/_newsletters.form.php b/inc/email_campaigns/views/_newsletters.form.php index dd23b1e0522..fd87a5df3cb 100644 --- a/inc/email_campaigns/views/_newsletters.form.php +++ b/inc/email_campaigns/views/_newsletters.form.php @@ -14,13 +14,13 @@ */ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); -global $current_User, $action, $edited_Newsletter; +global $action, $edited_Newsletter; $creating = is_create_action( $action ); $Form = new Form( NULL, 'newsletter_form' ); -if( ! $creating && $current_User->check_perm( 'emails', 'edit' ) ) +if( ! $creating && check_user_perm( 'emails', 'edit' ) ) { // Display a button to delete existing newsletter if current User has a perm: $Form->global_icon( TB_('Delete this list!'), 'delete', regenerate_url( 'action', 'action=delete&'.url_crumb( 'newsletter' ) ) ); } @@ -69,7 +69,7 @@ $Form->end_fieldset(); $buttons = array(); -if( $current_User->check_perm( 'emails', 'edit' ) ) +if( check_user_perm( 'emails', 'edit' ) ) { // Display a button to create/update newsletter if current User has a perm: if( $creating ) { // Create: diff --git a/inc/email_campaigns/views/_newsletters.view.php b/inc/email_campaigns/views/_newsletters.view.php index ec21ec4b161..d22950469a1 100644 --- a/inc/email_campaigns/views/_newsletters.view.php +++ b/inc/email_campaigns/views/_newsletters.view.php @@ -32,7 +32,7 @@ $Results->title = T_('Lists').get_manual_link( 'email-lists' ); -if( $current_User->check_perm( 'emails', 'edit' ) ) +if( check_user_perm( 'emails', 'edit' ) ) { // Display a button to add newsletter if current User has a perm: $Results->global_icon( T_('Create new list').'...', 'new', $admin_url.'?ctrl=newsletters&action=new', T_('Create new list').' »', 3, 4, array( 'class' => 'action_icon btn-primary' ) ); } @@ -47,8 +47,6 @@ function newsletters_td_active( $enlt_ID, $enlt_active ) { - global $current_User; - if( $enlt_active ) { // If newsletter is active: $active_icon = get_icon( 'bullet_green', 'imgtag', array( 'title' => T_('The list is active.') ) ); @@ -58,7 +56,7 @@ function newsletters_td_active( $enlt_ID, $enlt_active ) $active_icon = get_icon( 'bullet_empty_grey', 'imgtag', array( 'title' => T_('The list is not active.') ) ); } - if( $current_User->check_perm( 'emails', 'edit' ) ) + if( check_user_perm( 'emails', 'edit' ) ) { // Make icon to action link if current User has a perm to edit this: global $admin_url; return ''.$filetypes_allowed_icon.''; $filetypes_not_allowed_icon = ''.$filetypes_not_allowed_icon.''; @@ -374,28 +374,28 @@ function check_files_group_perm( $permlevel, $permvalue, $permtarget ) { // We have no perm level 'edit_allowed' for this root type, Use 'edit' instead: $permlevel = 'edit'; } - return $current_User->check_perm( 'shared_root', $permlevel ); + return check_user_perm( 'shared_root', $permlevel ); case 'import': if( $permlevel == 'edit_allowed' ) { // We have no perm level 'edit_allowed' for this root type, Use 'edit' instead: $permlevel = 'edit'; } - return $current_User->check_perm( 'import_root', $permlevel ); + return check_user_perm( 'import_root', $permlevel ); case 'skins': case 'siteskins': if( $permlevel == 'edit_allowed' ) { // We have no perm level 'edit_allowed' for this root type, Use 'edit' instead: $permlevel = 'edit'; } - return $current_User->check_perm( 'skins_root', $permlevel ); + return check_user_perm( 'skins_root', $permlevel ); case 'plugins': if( $permlevel == 'edit_allowed' ) { // We have no perm level 'edit_allowed' for this root type, Use 'edit' instead: $permlevel = 'edit'; } - return $current_User->check_perm( 'plugins_root', $permlevel ); + return check_user_perm( 'plugins_root', $permlevel ); case 'user': - if( $current_User->check_perm( 'users', 'moderate' ) && $current_User->check_perm( 'files', 'all' ) ) + if( check_user_perm( 'users', 'moderate' ) && check_user_perm( 'files', 'all' ) ) { // Current user can edits all files of other users return true; } @@ -411,7 +411,7 @@ function check_files_group_perm( $permlevel, $permvalue, $permtarget ) $perm = true; return $perm; } - if( $current_User->check_perm( 'blogs', $permlevel ) ) + if( check_user_perm( 'blogs', $permlevel ) ) { // If current user has access to view or edit all collections: $perm = true; return $perm; @@ -598,13 +598,12 @@ function build_evobar_menu() * @var Menu */ global $topleft_Menu; - global $current_User; global $admin_url; global $Collection, $Blog; - if( $current_User->check_perm( 'admin', 'standard' ) ) + if( check_user_perm( 'admin', 'standard' ) ) { - if( !empty($Blog) && $current_User->check_perm( 'files', 'view', false, $Blog->ID ) ) + if( !empty($Blog) && check_user_perm( 'files', 'view', false, $Blog->ID ) ) { // Manage blog files: // TODO: this is hackish and would require a proper function call @@ -620,9 +619,9 @@ function build_evobar_menu() } } - if( $current_User->check_perm( 'admin', 'restricted' ) ) + if( check_user_perm( 'admin', 'restricted' ) ) { - if( $current_User->check_perm( 'files', 'view', false, NULL ) ) + if( check_user_perm( 'files', 'view', false, NULL ) ) { // Manage files generally: // FM enabled and permission to view files: @@ -643,10 +642,6 @@ function build_evobar_menu() function build_menu_1() { global $blog, $admin_url; - /** - * @var User - */ - global $current_User; global $Collection, $Blog; global $Settings; /** @@ -654,12 +649,12 @@ function build_menu_1() */ global $AdminUI; - if( !$current_User->check_perm( 'admin', 'restricted' ) ) + if( ! check_user_perm( 'admin', 'restricted' ) ) { return; } - if( $current_User->check_perm( 'files', 'view', false, $blog ? $blog : NULL ) ) + if( check_user_perm( 'files', 'view', false, $blog ? $blog : NULL ) ) { // FM enabled and permission to view files: $AdminUI->add_menu_entries( NULL, array( 'files' => array( diff --git a/inc/files/file_moderation.ctrl.php b/inc/files/file_moderation.ctrl.php index b6dcafb4568..bf3cfa210d4 100644 --- a/inc/files/file_moderation.ctrl.php +++ b/inc/files/file_moderation.ctrl.php @@ -14,10 +14,10 @@ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); // Check permission: -$current_User->check_perm( 'files', 'view', true ); +check_user_perm( 'files', 'view', true ); // Check permission: -$current_User->check_perm( 'options', 'edit', true ); +check_user_perm( 'options', 'edit', true ); //param( 'action', 'string' ); diff --git a/inc/files/file_settings.ctrl.php b/inc/files/file_settings.ctrl.php index b374b04d4a4..212b2bceb0b 100644 --- a/inc/files/file_settings.ctrl.php +++ b/inc/files/file_settings.ctrl.php @@ -17,7 +17,7 @@ // Check minimum permission: -$current_User->check_perm( 'options', 'view', true ); +check_user_perm( 'options', 'view', true ); param( 'action', 'string' ); @@ -35,7 +35,7 @@ $Session->assert_received_crumb( 'file' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); param( 'submit', 'array:string', array() ); if( isset($submit['restore_defaults']) ) diff --git a/inc/files/file_types.ctrl.php b/inc/files/file_types.ctrl.php index 913efa489d1..44fbe2469a6 100644 --- a/inc/files/file_types.ctrl.php +++ b/inc/files/file_types.ctrl.php @@ -16,7 +16,7 @@ // Check minimum permission: -$current_User->check_perm( 'options', 'view', true ); +check_user_perm( 'options', 'view', true ); param( 'action', 'string' ); @@ -49,7 +49,7 @@ { case 'new': // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); $edited_Filetype = new Filetype(); $AdminUI->append_to_titlearea( TB_('Add a file type...') ); @@ -57,7 +57,7 @@ case 'copy': // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Duplicate a file type by prefilling create form: param( 'ftyp_ID', 'integer', true ); @@ -71,7 +71,7 @@ // Edit file type form...: // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure we got an ftyp_ID: param( 'ftyp_ID', 'integer', true ); @@ -86,7 +86,7 @@ $edited_Filetype = new Filetype(); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // load data from request if( $edited_Filetype->load_from_Request() ) @@ -123,7 +123,7 @@ $Session->assert_received_crumb( 'filetype' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure we got an ftyp_ID: param( 'ftyp_ID', 'integer', true ); @@ -150,7 +150,7 @@ $Session->assert_received_crumb( 'filetype' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure we got an ftyp_ID: param( 'ftyp_ID', 'integer', true ); diff --git a/inc/files/files.ctrl.php b/inc/files/files.ctrl.php index aa7fe7e1507..fc3db90c278 100644 --- a/inc/files/files.ctrl.php +++ b/inc/files/files.ctrl.php @@ -41,7 +41,7 @@ global $filename_max_length, $dirpath_max_length; // Check permission: -$current_User->check_perm( 'files', 'view', true, $blog ? $blog : NULL ); +check_user_perm( 'files', 'view', true, $blog ? $blog : NULL ); $AdminUI->set_path( 'files', 'browse' ); @@ -111,7 +111,7 @@ { // Found User, check perm: if( $edited_User->ID != $current_User->ID ) { // if not editing himself, must have user edit permission: - if( ! $current_User->check_perm( 'users', 'edit' ) ) + if( ! check_user_perm( 'users', 'edit' ) ) { $Messages->add( TB_('No permission to edit this user.'), 'error' ); unset( $edited_User ); @@ -160,6 +160,9 @@ param( 'field_name', 'string', '', true ); param( 'file_type', 'string', '', true ); +// Prefix +param( 'prefix', 'string', '' ); + // Get root: $ads_list_path = false; // false by default, gets set if we have a valid root /** @@ -175,7 +178,7 @@ { // We have requested a root folder by string: $fm_FileRoot = & $FileRootCache->get_by_ID( $root, true ); - if( ! $fm_FileRoot || ! isset( $available_Roots[$fm_FileRoot->ID] ) || ! $current_User->check_perm( 'files', 'view', false, $fm_FileRoot ) ) + if( ! $fm_FileRoot || ! isset( $available_Roots[$fm_FileRoot->ID] ) || ! check_user_perm( 'files', 'view', false, $fm_FileRoot ) ) { // Root not found or not in list of available ones $Messages->add( TB_('You don\'t have access to the requested root directory.'), 'error' ); $fm_FileRoot = false; @@ -188,7 +191,7 @@ /** * @var File */ - if( ( $avatar_File = & $edited_User->get_avatar_File() ) && ( $current_User->check_perm( 'files', 'view', false, $avatar_File->get_FileRoot() ) ) ) + if( ( $avatar_File = & $edited_User->get_avatar_File() ) && ( check_user_perm( 'files', 'view', false, $avatar_File->get_FileRoot() ) ) ) { $fm_FileRoot = & $avatar_File->get_FileRoot(); $path = dirname( $avatar_File->get_rdfs_rel_path() ).'/'; @@ -205,7 +208,7 @@ * @var File */ $File = & $FileList->get_next(); - if( !empty( $File ) && $current_User->check_perm( 'files', 'view', false, $File->get_FileRoot() ) ) + if( !empty( $File ) && check_user_perm( 'files', 'view', false, $File->get_FileRoot() ) ) { // Obtain and use file root of first file: $fm_FileRoot = & $File->get_FileRoot(); $path = dirname( $File->get_rdfs_rel_path() ).'/'; @@ -213,7 +216,7 @@ } } -if( $fm_FileRoot && ! $current_User->check_perm( 'files', 'view', false, $fm_FileRoot ) ) +if( $fm_FileRoot && ! check_user_perm( 'files', 'view', false, $fm_FileRoot ) ) { $fm_FileRoot = false; }; @@ -244,7 +247,7 @@ { foreach( $available_Roots as $l_FileRoot ) { - if( $current_User->check_perm( 'files', 'view', false, $l_FileRoot ) ) + if( check_user_perm( 'files', 'view', false, $l_FileRoot ) ) { $fm_FileRoot = $l_FileRoot; break; @@ -275,24 +278,34 @@ // Dereference any /../ just to make sure, and CHECK if directory exists: $ads_list_path = get_canonical_path( $non_canonical_list_path ); - if( !is_dir( $ads_list_path ) ) - { // This should never happen, but just in case the diretory does not exist: - $Messages->add( sprintf( TB_('The directory «%s» does not exist.'), $path ), 'error' ); - $path = ''; // fp> added - $ads_list_path = NULL; - } - elseif( ! preg_match( '#^'.preg_quote($fm_FileRoot->ads_path, '#').'#', $ads_list_path ) ) + if( ! preg_match( '#^'.preg_quote( $fm_FileRoot->ads_path, '#' ).'#', $ads_list_path ) ) { // cwd is OUTSIDE OF root! $Messages->add( TB_( 'You are not allowed to go outside your root directory!' ), 'error' ); $path = ''; // fp> added $ads_list_path = $fm_FileRoot->ads_path; } + + if( $ajax_request && + ! is_dir( $ads_list_path ) && + ! file_exists( $ads_list_path ) && + check_user_perm( 'files', 'add', false, $fm_FileRoot ) ) + { // Try to create the requested directory automatically if current User + // has a permission and when this is a request e.g. for an import folder: + mkdir_r( $ads_list_path ); + } + + if( ! is_dir( $ads_list_path ) ) + { // This may happens when a requested folder e.g. /media/import/users/ doesn't exist: + $Messages->add( sprintf( TB_('The directory «%s» does not exist.'), $path ), 'error' ); + $path = ''; // fp> added + $ads_list_path = NULL; + } elseif( $ads_list_path != $non_canonical_list_path ) { // We have reduced the absolute path, we should also reduce the relative $path (used in urls params) $path = get_canonical_path( $path ); } - if( ( $Messages->count() == 0 ) && ( strlen( $ads_list_path ) > $dirpath_max_length ) && $current_User->check_perm( 'options', 'edit' ) ) + if( ( $Messages->count() == 0 ) && ( strlen( $ads_list_path ) > $dirpath_max_length ) && check_user_perm( 'options', 'edit' ) ) { // This folder absolute path exceed the max allowed length, a warning message must be displayed, if there were no other message yet. ( If there are other messages then this one should have been already added ) $Messages->add( sprintf( TB_( 'This folder has an access path that is too long and cannot be properly handled by b2evolution. Please check and increase the «%s» variable.'), '$dirpath_max_length' ), 'warning' ); } @@ -373,7 +386,7 @@ if( $action == 'createnew' ) { // Check permission: - $current_User->check_perm( 'files', 'add', true, $blog ? $blog : NULL ); + check_user_perm( 'files', 'add', true, $blog ? $blog : NULL ); // create new file/dir param( 'create_type', 'string', true ); // 'file', 'dir' @@ -399,7 +412,7 @@ $Session->assert_received_crumb( 'file' ); // Check permission: - $current_User->check_perm( 'files', 'add', true, $blog ? $blog : NULL ); + check_user_perm( 'files', 'add', true, $blog ? $blog : NULL ); if( ! $Settings->get( 'fm_enable_create_dir' ) ) { // Directory creation is gloablly disabled: @@ -461,7 +474,7 @@ $Session->assert_received_crumb( 'file' ); // Check permission: - $current_User->check_perm( 'files', 'add', true, $blog ? $blog : NULL ); + check_user_perm( 'files', 'add', true, $blog ? $blog : NULL ); if( ! $Settings->get( 'fm_enable_create_file' ) ) { // File creation is gloablly disabled: @@ -474,7 +487,7 @@ $Messages->add( TB_('Cannot create a file without name.'), 'error' ); break; } - if( $error_filename = validate_filename( $create_name, $current_User->check_perm( 'files', 'all' ) ) ) + if( $error_filename = validate_filename( $create_name, check_user_perm( 'files', 'all' ) ) ) { // Not valid filename or extension $Messages->add( $error_filename, 'error' ); syslog_insert( sprintf( 'The creating file %s has an unrecognized extension', '[['.$create_name.']]' ), 'warning', 'file' ); @@ -552,13 +565,13 @@ } // Check permission! - $current_User->check_perm( 'files', 'edit_allowed', true, $selected_Filelist->get_FileRoot() ); + check_user_perm( 'files', 'edit_allowed', true, $selected_Filelist->get_FileRoot() ); // Get the file we want to update: $edited_File = & $selected_Filelist->get_by_idx(0); // Check that the file is editable: - if( ! $edited_File->is_editable( $current_User->check_perm( 'files', 'all' ) ) ) + if( ! $edited_File->is_editable( check_user_perm( 'files', 'all' ) ) ) { $Messages->add( sprintf( TB_( 'You are not allowed to edit «%s».' ), $edited_File->dget('name') ), 'error' ); break; @@ -640,7 +653,7 @@ if( $action == 'create_zip' ) { // Check permission for action to create new ZIP archive: - $current_User->check_perm( 'files', 'edit_allowed', true, $selected_Filelist->get_FileRoot() ); + check_user_perm( 'files', 'edit_allowed', true, $selected_Filelist->get_FileRoot() ); } if( !$selected_Filelist->count() ) @@ -742,7 +755,7 @@ // Unpack selected ZIP archives: // Check permission for action to edit files in the selected File Root: - $current_User->check_perm( 'files', 'edit_allowed', true, $selected_Filelist->get_FileRoot() ); + check_user_perm( 'files', 'edit_allowed', true, $selected_Filelist->get_FileRoot() ); if( ! $selected_Filelist->count() ) { @@ -762,14 +775,14 @@ // Rename/Move/Copy a file: // This will not allow to overwrite existing files, the same way Windows and MacOS do not allow it. Adding an option will only clutter the interface and satisfy geeks only. - if( ! $current_User->check_perm( 'files', 'edit_allowed', false, $selected_Filelist->get_FileRoot() ) ) + if( ! check_user_perm( 'files', 'edit_allowed', false, $selected_Filelist->get_FileRoot() ) ) { // We do not have permission to edit files $Messages->add( TB_('You have no permission to edit/modify files.'), 'error' ); $action = 'list'; break; } - $allow_locked_filetypes = $current_User->check_perm( 'files', 'all' ); + $allow_locked_filetypes = check_user_perm( 'files', 'all' ); $sources_Root = & $FileRootCache->get_by_ID( $fm_sources_root ); if( $sources_Root ) @@ -960,7 +973,7 @@ break; case 'resize': - if( ! $current_User->check_perm( 'files', 'edit_allowed', false, $selected_Filelist->get_FileRoot() ) ) + if( ! check_user_perm( 'files', 'edit_allowed', false, $selected_Filelist->get_FileRoot() ) ) { // We do not have permission to edit files $Messages->add( TB_('You have no permission to edit/modify files.'), 'error' ); $action = 'list'; @@ -1022,7 +1035,7 @@ // Check that this action request is not a CSRF hacked request: $Session->assert_received_crumb( 'file' ); - if( ! $current_User->check_perm( 'files', 'edit_allowed', false, $selected_Filelist->get_FileRoot() ) ) + if( ! check_user_perm( 'files', 'edit_allowed', false, $selected_Filelist->get_FileRoot() ) ) { // We do not have permission to edit files $Messages->add( TB_('You have no permission to edit/modify files.'), 'error' ); $action = 'list'; @@ -1245,13 +1258,13 @@ $Session->assert_received_crumb( 'file' ); // Check permission! - $current_User->check_perm( 'files', 'edit_allowed', true, $blog ? $blog : NULL ); + check_user_perm( 'files', 'edit_allowed', true, $blog ? $blog : NULL ); // Get the file we want to edit: $edited_File = & $selected_Filelist->get_by_idx(0); // Check that the file is editable: - if( ! $edited_File->is_editable( $current_User->check_perm( 'files', 'all' ) ) ) + if( ! $edited_File->is_editable( check_user_perm( 'files', 'all' ) ) ) { $Messages->add( sprintf( TB_( 'You are not allowed to edit «%s».' ), $edited_File->dget('name') ), 'error' ); // Leave special display mode: @@ -1281,7 +1294,7 @@ $Session->assert_received_crumb( 'file' ); // Check permission! - $current_User->check_perm( 'files', 'edit_allowed', true, $selected_Filelist->get_FileRoot() ); + check_user_perm( 'files', 'edit_allowed', true, $selected_Filelist->get_FileRoot() ); $edited_File = & $selected_Filelist->get_by_idx(0); $edited_File->load_meta(); @@ -1300,7 +1313,7 @@ $Session->assert_received_crumb( 'file' ); // Check permission! - $current_User->check_perm( 'files', 'edit_allowed', true, $selected_Filelist->get_FileRoot() ); + check_user_perm( 'files', 'edit_allowed', true, $selected_Filelist->get_FileRoot() ); param( 'link_owner_type', 'string', '' ); param( 'link_owner_ID', 'integer', 0 ); @@ -1351,7 +1364,7 @@ if( $new_name != $old_name) { // Name has changed... - $allow_locked_filetypes = $current_User->check_perm( 'files', 'all' ); + $allow_locked_filetypes = check_user_perm( 'files', 'all' ); if( $check_error = check_rename( $new_name, $edited_File->is_dir(), $edited_File->get_dir(), $allow_locked_filetypes ) ) { $error_occured = true; @@ -1572,7 +1585,7 @@ // Check that this action request is not a CSRF hacked request: $Session->assert_received_crumb( 'file' ); - if( ! $current_User->check_perm( 'files', 'edit_allowed', false, $selected_Filelist->get_FileRoot() ) ) + if( ! check_user_perm( 'files', 'edit_allowed', false, $selected_Filelist->get_FileRoot() ) ) { // We do not have permission to edit files $Messages->add( TB_('You have no permission to edit/modify files.'), 'error' ); $action = 'list'; @@ -1701,8 +1714,6 @@ { // require colorbox js require_js_helper( 'colorbox' ); - // Init JS to quick upload several files: - init_fileuploader_js( 'rsc_url', false ); if( $mode == 'upload' || $mode == 'import' ) { // Add css to remove spaces around window @@ -1831,9 +1842,44 @@ // ------------------- // Browsing interface: // ------------------- - // Display VIEW: - $AdminUI->disp_view( 'files/views/_file_browse.view.php' ); - + $show_existing_attachments_tab = ( $mode == 'upload' ) && isset( $LinkOwner ) && in_array( get_class( $LinkOwner->link_Object ), array( 'Comment', 'Item', 'EmailCampaign' ) ); + if( $show_existing_attachments_tab ) + { // Display existing attachments tab: + $attach_files_url = get_htsrv_url().'async.php?action=browse_existing_attachments&root='.$root + .'&path='.$path + .'&prefix='.$prefix + .'&link_type='.( $LinkOwner->is_temp() ? 'temporary' : $LinkOwner->type ) + .( $LinkOwner->type != 'message' ? '&link_object_ID='.$LinkOwner->get_ID() : '' ); + ?> +
    + +
    +
    +
    + disp_view( 'files/views/_file_browse.view.php' ); + ?> +
    +
    +
    + disp_view( 'files/views/_file_browse.view.php' ); + } // End payload block: $AdminUI->disp_payload_end(); @@ -1842,4 +1888,4 @@ $AdminUI->disp_global_footer(); } -?> \ No newline at end of file +?> diff --git a/inc/files/model/_file.class.php b/inc/files/model/_file.class.php index d7a21084699..73e93ce6dfa 100644 --- a/inc/files/model/_file.class.php +++ b/inc/files/model/_file.class.php @@ -1360,7 +1360,7 @@ function get_size_formatted() * @param string rel= attribute of link, usefull for jQuery libraries selecting on rel='...', e-g: lightbox * @param string image class= * @param string image align= - * @param string image alt= + * @param string image alt=, Use '-' in order to don't display any alt text * @param string image caption/description to be displayed under the image * @param integer Link ID * @param integer Size multiplier, can be 1, 2 and etc. (Used for b2evonet slider for example) @@ -1439,8 +1439,15 @@ function get_tag( $before_image = '
    ', $img_attribs['align'] = $image_align; } - if( $img_attribs['alt'] == '' ) - { // Image alt + if( $image_alt == '-' ) + { // Don't display any alt text: + if( isset( $img_attribs['alt'] ) ) + { + unset( $img_attribs['alt'] ); + } + } + elseif( $image_alt != '' ) + { // Overrride original image alt store in DB per this File: $img_attribs['alt'] = $image_alt; } @@ -2693,6 +2700,16 @@ function get_img_attribs( $size_name = 'fit-80x80', $title = NULL, $alt = NULL, } } } + elseif( substr( $this->_adfp_full_path, -4 ) == '.svg' ) + { // Special case for SVG file because we cannot generate thumbnail for this file type: + $img_attribs['src'] = $this->get_url(); + global $thumbnail_sizes; + if( isset( $thumbnail_sizes[ $size_name ] ) ) + { // Set attributes for SVG file from config of thumbnail sizes: + $img_attribs['width'] = $thumbnail_sizes[ $size_name ][1]; + $img_attribs['height'] = $thumbnail_sizes[ $size_name ][2]; + } + } else { // We want src to link to a generated thumbnail: $img_attribs['src'] = $this->get_thumb_url( $size_name, '&', $size_x ); @@ -3325,10 +3342,8 @@ function get_restriction_link( $restriction ) */ function get_target_icon() { - global $current_User; - $r = ''; - if( $current_User->check_perm( 'files', 'view', false, $this->get_FileRoot() ) ) + if( check_user_perm( 'files', 'view', false, $this->get_FileRoot() ) ) { // Check permission if( $this->is_dir() ) { // Dir @@ -3400,7 +3415,7 @@ function set_file_type() // IMAGE: // File type is still not defined, Try to detect image - if( $this->get_image_size() !== false ) + if( is_image_file( $this->_adfp_full_path ) || $this->get_image_size() !== false ) { // This is image file $this->update_file_type( 'image' ); return; diff --git a/inc/files/model/_file.funcs.php b/inc/files/model/_file.funcs.php index 673f12834aa..93da9282522 100644 --- a/inc/files/model/_file.funcs.php +++ b/inc/files/model/_file.funcs.php @@ -371,10 +371,15 @@ function is_image_file( $file_path ) return false; } + if( substr( $file_path, -4 ) == '.svg' ) + { // Consider all SVG file is image, because not SVG files has a mime type as 'image/svg': + return true; + } + $file_info = finfo_open( FILEINFO_MIME_TYPE ); $file_type = finfo_file( $file_info, $file_path ); - return in_array( $file_type, array( 'image/png', 'image/jpeg', 'image/gif' ) ); + return in_array( $file_type, array( 'image/png', 'image/jpeg', 'image/gif', 'image/svg', 'image/svg+xml' ) ); } /** @@ -780,12 +785,12 @@ function get_upload_restriction( $params = array() ) 'ext_last_separator' => ' & ', ), $params ); - global $DB, $Settings, $current_User; + global $DB, $Settings; $restrictNotes = array(); if( is_logged_in( false ) ) { - $condition = ( $current_User->check_perm( 'files', 'all' ) && !empty( $admins_can_manipulate_sensitive_files ) ) ? '' : 'ftyp_allowed <> "admin"'; + $condition = ( check_user_perm( 'files', 'all' ) && !empty( $admins_can_manipulate_sensitive_files ) ) ? '' : 'ftyp_allowed <> "admin"'; } else { @@ -868,10 +873,8 @@ function rel_path_to_base( $path ) */ function get_directory_tree( $Root = NULL, $ads_full_path = NULL, $ads_selected_full_path = NULL, $radios = false, $rds_rel_path = NULL, $is_recursing = false, $action = 'view' ) { - static $js_closeClickIDs; // clickopen IDs that should get closed static $instance_ID = 0; static $fm_highlight; - global $current_User; // A folder might be highlighted (via "Locate this directory!") if( ! isset($fm_highlight) ) @@ -884,7 +887,6 @@ function get_directory_tree( $Root = NULL, $ads_full_path = NULL, $ads_selected_ { // This is not a recursive call (yet): // Init: $instance_ID++; - $js_closeClickIDs = array(); $ret = '
      '; } else @@ -899,7 +901,7 @@ function get_directory_tree( $Root = NULL, $ads_full_path = NULL, $ads_selected_ foreach( $_roots as $l_Root ) { - if( ! $current_User->check_perm( 'files', $action, false, $l_Root ) ) + if( ! check_user_perm( 'files', $action, false, $l_Root ) ) { // current user does not have permission to "view" (or other $action) this root continue; } @@ -921,38 +923,38 @@ function get_directory_tree( $Root = NULL, $ads_full_path = NULL, $ads_selected_ $id_path = 'id_path_'.$instance_ID.md5( $ads_full_path ); - $r['string'] = 'ID, $rds_rel_path) ), 'formvalue' ); - $r['string'] .= ''' ) ).' '.$label.''; + $r .= get_icon( 'expand', 'noimg', array( 'class'=>'' ) ).$label.''; } else { // Process subdirs - $r['string'] .= get_icon( 'collapse', 'imgtag', array( 'onclick' => 'toggle_clickopen(\''.$id_path.'\');', - 'id' => 'clickimg_'.$id_path, + $r .= get_icon( $dir_is_opened ? 'collapse' : 'expand', 'imgtag', array( + 'data-dir-path' => $Root->ID.':'.$rds_rel_path, 'style'=>'margin:0 2px' ) ) - .' '.$label.'' - .'
        '."\n"; - - while( $l_File = & $Nodelist->get_next( 'dir' ) ) - { - $rSub = get_directory_tree( $Root, $l_File->get_full_path(), $ads_selected_full_path, $radios, $l_File->get_rdfs_rel_path(), true ); + .$label.''; - if( $rSub['opened'] ) - { // pass opened status on, if given - $r['opened'] = $rSub['opened']; - } + if( $dir_is_opened ) + { // Load sub-directories only of currently opened directory: + $r .= //'
        - '.$ads_full_path.'
        - '.$ads_selected_full_path.'
        - '.$rds_rel_path + '
          '."\n"; - $r['string'] .= '
        • '.$rSub['string'].'
        • '; - } + while( $l_File = & $Nodelist->get_next( 'dir' ) ) + { + $r_sub = get_directory_tree( $Root, $l_File->get_full_path(), $ads_selected_full_path, $radios, $l_File->get_rdfs_rel_path(), true ); - if( !$r['opened'] ) - { - $js_closeClickIDs[] = $id_path; + $r .= '
        • '.$r_sub.'
        • '; + } + $r .= '
        '; } - $r['string'] .= '
      '; } - if( $is_recursing ) + if( $is_recursing ) { return $r; } else { - $ret .= '
    • '.$r['string'].'
    • '; + $ret .= '
    • '.$r.'
    • '; } } if( ! $is_recursing ) { - $ret .= '
    '; - - if( ! empty($js_closeClickIDs) ) - { // there are IDs of checkboxes that we want to close - $ret .= "\n".'"; - } + $ret .= ''; } return $ret; @@ -1265,7 +1255,7 @@ function is_absolute_pathname($path) */ function file_controller_build_tabs() { - global $AdminUI, $current_User, $blog, $admin_url; + global $AdminUI, $blog, $admin_url; $AdminUI->add_menu_entries( 'files', @@ -1276,7 +1266,7 @@ function file_controller_build_tabs() ) ); - if( $current_User->check_perm( 'options', 'view' ) ) + if( check_user_perm( 'options', 'view' ) ) { // Permission to view settings: $AdminUI->add_menu_entries( 'files', @@ -1301,7 +1291,7 @@ function file_controller_build_tabs() ); } - if( $current_User->check_perm( 'options', 'edit' ) ) + if( check_user_perm( 'options', 'edit' ) ) { // Permission to edit settings: $AdminUI->add_menu_entries( 'files', @@ -1486,7 +1476,7 @@ function process_upload( $root_ID, $path, $create_path_dirs = false, $check_perm return NULL; } - if( $check_perms && ( !isset( $current_User ) || $current_User->check_perm( 'files', 'add', false, $fm_FileRoot ) ) ) + if( $check_perms && ( !isset( $current_User ) || check_user_perm( 'files', 'add', false, $fm_FileRoot ) ) ) { // Permission check required but current User has no permission to upload: return NULL; } @@ -2141,7 +2131,7 @@ function copy_file( $file_path, $root_ID, $path, $check_perms = true ) return NULL; } - if( $check_perms && ( !isset( $current_User ) || $current_User->check_perm( 'files', 'add', false, $fm_FileRoot ) ) ) + if( $check_perms && ( !isset( $current_User ) || check_user_perm( 'files', 'add', false, $fm_FileRoot ) ) ) { // Permission check required but current User has no permission to upload: return NULL; } @@ -2357,16 +2347,17 @@ function create_htaccess_deny( $dir ) */ function display_dragdrop_upload_button( $params = array() ) { - global $blog, $Settings, $current_User, $b2evo_icons_type, $DB, $admins_can_manipulate_sensitive_files; + global $blog, $Settings, $b2evo_icons_type, $DB, $admins_can_manipulate_sensitive_files; $params = array_merge( array( - 'before' => '', - 'after' => '', - 'fileroot_ID' => 0, // Root type and ID, e.g. collection_1 - 'path' => '', // Subpath for the file/folder - 'listElement' => 'null', - 'list_style' => 'list', // 'list' or 'table' - 'template' => '
    + 'before' => '', + 'after' => '', + 'fileroot_ID' => 0, // Root type and ID, e.g. collection_1 + 'path' => '', // Subpath for the file/folder + 'listElement' => 'null', + 'list_element' => NULL, //jQuery selector of list element + 'list_style' => 'list', // 'list' or 'table' + 'template' => '
    @@ -2449,6 +2440,9 @@ function display_dragdrop_upload_button( $params = array() ) return; } + // Initialize quick uploader: + init_fileuploader_js( ( is_admin_page() ? 'rsc_url' : 'blog' ), ( $LinkOwner !== NULL /* Sortable only attached files */ ) ); + $root_and_path = $params['fileroot_ID'].'::'.$params['path']; $quick_upload_url = get_htsrv_url().'quick_upload.php' .'?b2evo_icons_type='.$b2evo_icons_type @@ -2461,13 +2455,13 @@ function display_dragdrop_upload_button( $params = array() ) { // Use this field to know a form is submitted with temporary link owner(when object is creating and still doesn't exist in DB): echo ''; // Set correct name only when JS is enabled: - echo ''; + echo ''; } // Get list of allowed filetype extensions if( is_logged_in( false ) ) { - $condition = ( $current_User->check_perm( 'files', 'all' ) && !empty($admins_can_manipulate_sensitive_files) ) ? '' : 'ftyp_allowed <> "admin"'; + $condition = ( check_user_perm( 'files', 'all' ) && !empty($admins_can_manipulate_sensitive_files) ) ? '' : 'ftyp_allowed <> "admin"'; } else { @@ -2490,495 +2484,84 @@ function display_dragdrop_upload_button( $params = array() )
    - - document.write( '

    ' + file_uploader_note_text + '

    ' ); - - + } + else + { + expose_var_to_js( 'fieldset_'.$params['fieldset_prefix'], $dragdrop_upload_button_config, 'evo_init_dragdrop_button_config' ); + } + ?> \ No newline at end of file + diff --git a/inc/files/views/_file_browse_set.form.php b/inc/files/views/_file_browse_set.form.php index f027d27daf6..5e22f2c72b4 100644 --- a/inc/files/views/_file_browse_set.form.php +++ b/inc/files/views/_file_browse_set.form.php @@ -62,7 +62,7 @@ array( 'value'=>'regexp', 'label'=>TB_('With regular expressions') ) ), TB_('Filter box') ); $Form->end_fieldset(); -if( $current_User->check_perm( 'options', 'edit', false ) ) +if( check_user_perm( 'options', 'edit', false ) ) { // TODO: better perm check /** * @var FileRoot diff --git a/inc/files/views/_file_duplicates.view.php b/inc/files/views/_file_duplicates.view.php index 0f55c868583..d1b64dfeb73 100644 --- a/inc/files/views/_file_duplicates.view.php +++ b/inc/files/views/_file_duplicates.view.php @@ -90,7 +90,7 @@ * Group columns: */ $Results->grp_cols[] = array( - 'td_class' => 'firstcol'.($current_User->check_perm( 'users', 'edit', false ) ? '' : ' lastcol' ), + 'td_class' => 'firstcol'.(check_user_perm( 'users', 'edit', false ) ? '' : ' lastcol' ), 'td_colspan' => 0, 'td' => sprintf( T_('%s duplicates'), '$total_duplicates$' ), ); @@ -139,9 +139,8 @@ function td_file_duplicates_path( $File, $file_root_type, $file_root_ID, $file_p { if( is_object( $File ) ) { // Check if File object is correct - global $current_User; $r = $File->get_view_link().' '.$File->get_target_icon(); - if( $current_User->check_perm( 'files', 'edit_allowed', false, $File->get_FileRoot() ) ) + if( check_user_perm( 'files', 'edit_allowed', false, $File->get_FileRoot() ) ) { // Allow to delete a file only if current user has an access global $admin_url; $r .= action_icon( T_('Delete'), 'file_delete', @@ -176,8 +175,7 @@ function td_file_duplicates_path( $File, $file_root_type, $file_root_ID, $file_p function td_file_properties_link( $File, $link_text ) { - global $current_User; - if( is_object( $File ) && $current_User->check_perm( 'files', 'edit_allowed', false, $File->get_FileRoot() ) ) + if( is_object( $File ) && check_user_perm( 'files', 'edit_allowed', false, $File->get_FileRoot() ) ) { // Check if File object is correct and current user has an access return ''.$link_text.''; } diff --git a/inc/files/views/_file_likes.view.php b/inc/files/views/_file_likes.view.php index 811583b1124..84021104e3b 100644 --- a/inc/files/views/_file_likes.view.php +++ b/inc/files/views/_file_likes.view.php @@ -90,8 +90,7 @@ function callback_filter_file_suspicious( & $Form ) function td_file_properties_link( $File, $link_text ) { - global $current_User; - if( is_object( $File ) && $current_User->check_perm( 'files', 'edit_allowed', false, $File->get_FileRoot() ) ) + if( is_object( $File ) && check_user_perm( 'files', 'edit_allowed', false, $File->get_FileRoot() ) ) { // Check if File object is correct and current user has an access return ''.$link_text.''; } diff --git a/inc/files/views/_file_links.view.php b/inc/files/views/_file_links.view.php index 40bb5156eae..6ac33c90e0b 100644 --- a/inc/files/views/_file_links.view.php +++ b/inc/files/views/_file_links.view.php @@ -74,11 +74,11 @@ function file_path() /** * @global File */ - global $current_File, $current_User; + global $current_File; global $LinkOwner; $r = T_( 'You don\'t have permission to access this file root' ); - if( $current_User->check_perm( 'files', 'view', false, $current_File->get_FileRoot() ) ) + if( check_user_perm( 'files', 'view', false, $current_File->get_FileRoot() ) ) { // File relative path & name: $r = $current_File->get_linkedit_link( $LinkOwner->type, $LinkOwner->get_ID() ); diff --git a/inc/files/views/_file_list.inc.php b/inc/files/views/_file_list.inc.php index f92ba59683b..742a5ea7056 100644 --- a/inc/files/views/_file_list.inc.php +++ b/inc/files/views/_file_list.inc.php @@ -27,10 +27,6 @@ * @var string */ global $fm_flatmode; -/** - * @var User - */ -global $current_User; /** * @var UserSettings */ @@ -169,8 +165,8 @@ $fm_highlight = param( 'fm_highlight', 'string', NULL ); // Set FileList perms - $all_perm = $current_User->check_perm( 'files', 'all', false ); - $edit_allowed_perm = $current_User->check_perm( 'files', 'edit_allowed', false, $fm_Filelist->get_FileRoot() ); + $all_perm = check_user_perm( 'files', 'all', false ); + $edit_allowed_perm = check_user_perm( 'files', 'edit_allowed', false, $fm_Filelist->get_FileRoot() ); /***********************************************************/ /* MAIN FILE LIST: */ @@ -190,7 +186,6 @@ /******************** Checkbox: *******************/ echo ''; - echo ''; echo 'contains( $lFile ) ) @@ -198,7 +193,6 @@ echo ' checked="checked"'; } echo ' />'; - echo ''; /*********** Hidden info used by Javascript: ***********/ @@ -502,7 +496,7 @@ // ------------- // Quick upload with drag&drop button: // -------------- - if( $Settings->get( 'upload_enabled' ) && $current_User->check_perm( 'files', 'add', false, $fm_FileRoot ) ) + if( $Settings->get( 'upload_enabled' ) && check_user_perm( 'files', 'add', false, $fm_FileRoot ) ) { // Upload is enabled and we have permission to use it... ?> @@ -616,18 +610,19 @@ // Display a button to quick upload the files by drag&drop method display_dragdrop_upload_button( array( - 'fileroot_ID' => $fm_FileRoot->ID, - 'path' => $path, - 'listElement' => 'jQuery( ".filelist_tbody" ).get(0)', - 'list_style' => 'table', - 'template' => $template, - 'display_support_msg' => false, + 'fileroot_ID' => $fm_FileRoot->ID, + 'path' => empty( $path ) ? './' : $path, + 'listElement' => 'jQuery( ".filelist_tbody" ).get(0)', + 'list_element' => '.filelist_tbody', + 'list_style' => 'table', + 'template' => $template, + 'display_support_msg' => false, 'display_status_success' => false, - 'additional_dropzone' => '[ jQuery( ".filelist_tbody" ).get(0) ]', - 'filename_before' => $icon_to_link_files, - 'table_headers' => $table_headers, - 'noresults' => $noresults, - 'table_id' => 'FilesForm', + 'additional_dropzone' => '[ jQuery( ".filelist_tbody" ).get(0) ]', + 'filename_before' => $icon_to_link_files, + 'table_headers' => $table_headers, + 'noresults' => $noresults, + 'table_id' => 'FilesForm', ) ); ?> @@ -644,7 +639,7 @@ '; - echo $Form->check_all(); + $Form->checkbox_controls( 'fm_selected', array( 'button_class' => 'btn btn-default' ) ); $Form->add_crumb( 'file' ); $field_options = array(); @@ -659,9 +654,9 @@ } if( ( $fm_Filelist->get_root_type() == 'collection' || ( ! empty( $Blog ) - && $current_User->check_perm( 'blog_post_statuses', 'edit', false, $Blog->ID ) ) ) + && check_user_perm( 'blog_post_statuses', 'edit', false, $Blog->ID ) ) ) && $mode != 'upload' - && $current_User->check_perm( 'admin', 'normal' ) ) + && check_user_perm( 'admin', 'normal' ) ) { // We are browsing files for a collection: // User must have access to admin permission // fp> TODO: use current as default but let user choose into which blog he wants to post @@ -735,7 +730,7 @@ * CREATE FILE/FOLDER CREATE PANEL: */ if( ( $Settings->get( 'fm_enable_create_dir' ) || $Settings->get( 'fm_enable_create_file' ) ) - && $current_User->check_perm( 'files', 'add', false, $fm_FileRoot ) ) + && check_user_perm( 'files', 'add', false, $fm_FileRoot ) ) { // dir or file creation is enabled and we're allowed to add files: global $create_type; @@ -913,4 +908,4 @@ function insert_tag_for_selected_files() }}} ?> - \ No newline at end of file + diff --git a/inc/files/views/_file_properties.form.php b/inc/files/views/_file_properties.form.php index b59d36d9daf..d7ab53fec7b 100644 --- a/inc/files/views/_file_properties.form.php +++ b/inc/files/views/_file_properties.form.php @@ -22,7 +22,7 @@ global $Settings, $admin_url; -$edit_allowed_perm = $current_User->check_perm( 'files', 'edit_allowed', false, $selected_Filelist->get_FileRoot() ); +$edit_allowed_perm = check_user_perm( 'files', 'edit_allowed', false, $selected_Filelist->get_FileRoot() ); $Form = new Form( $admin_url, 'fm_properties_checkchanges' ); diff --git a/inc/files/views/_file_settings.form.php b/inc/files/views/_file_settings.form.php index 44686eddde6..cc215ca5d17 100644 --- a/inc/files/views/_file_settings.form.php +++ b/inc/files/views/_file_settings.form.php @@ -232,7 +232,7 @@ function JS_showhide_ffield_on_this( $field_id ) $Form->end_fieldset(); -if( $current_User->check_perm( 'options', 'edit', false ) ) +if( check_user_perm( 'options', 'edit', false ) ) { // We have permission to modify: $Form->buttons( array( array( 'submit', 'submit[update]', TB_('Save Changes!'), 'SaveButton' ), @@ -242,7 +242,7 @@ function JS_showhide_ffield_on_this( $field_id ) $Form->end_form(); -if( $current_User->check_perm( 'options', 'edit', false ) ) +if( check_user_perm( 'options', 'edit', false ) ) { // TODO: better perm check echo '

    '.TB_('See also:').' '; echo TB_('Blog Settings').' > '.TB_('Advanced').' > '.TB_('Media directory location'); diff --git a/inc/files/views/_filetype_list.view.php b/inc/files/views/_filetype_list.view.php index ad4c72f86a6..f613ce343da 100644 --- a/inc/files/views/_filetype_list.view.php +++ b/inc/files/views/_filetype_list.view.php @@ -36,7 +36,7 @@ 'td' => '% {Obj}->get_icon() %', ); -if( $current_User->check_perm( 'options', 'edit', false ) ) +if( check_user_perm( 'options', 'edit', false ) ) { // We have permission to modify: $Results->cols[] = array( 'th' => T_('Extensions'), @@ -110,7 +110,7 @@ function display_perm( $perm ) 'td' => '%display_perm( #ftyp_allowed# )%', ); -if( $current_User->check_perm( 'options', 'edit', false ) ) +if( check_user_perm( 'options', 'edit', false ) ) { // We have permission to modify: $Results->cols[] = array( diff --git a/inc/items/item_statuses.ctrl.php b/inc/items/item_statuses.ctrl.php index 25b30d22713..788e61ff045 100644 --- a/inc/items/item_statuses.ctrl.php +++ b/inc/items/item_statuses.ctrl.php @@ -19,7 +19,7 @@ // Check minimum permission: -$current_User->check_perm( 'options', 'view', true ); +check_user_perm( 'options', 'view', true ); // We should activate toolbar menu items for this controller $activate_collection_toolbar = true; @@ -50,7 +50,7 @@ case 'new': // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); if( ! isset( $edited_ItemStatus ) ) { // We don't have a model to use, start with blank object: @@ -66,7 +66,7 @@ case 'edit': // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure we got an pst_ID: param( 'pst_ID', 'integer', true ); @@ -83,7 +83,7 @@ $edited_ItemStatus = new ItemStatus(); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // load data from request if( $edited_ItemStatus->load_from_Request() ) @@ -125,7 +125,7 @@ $Session->assert_received_crumb( 'itemstatus' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure we got an pst_ID: param( 'pst_ID', 'integer', true ); @@ -149,7 +149,7 @@ $Session->assert_received_crumb( 'itemstatus' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure we got an pst_ID: param( 'pst_ID', 'integer', true ); @@ -195,6 +195,7 @@ $AdminUI->set_page_manual_link( 'managing-item-statuses-form' ); break; default: + require_js_defer( 'customized:jquery/jeditable/jquery.jeditable.js', 'rsc_url' ); $AdminUI->set_page_manual_link( 'managing-item-statuses' ); break; } diff --git a/inc/items/item_tags.ctrl.php b/inc/items/item_tags.ctrl.php index 0469a8edbb4..d2b82649e9c 100644 --- a/inc/items/item_tags.ctrl.php +++ b/inc/items/item_tags.ctrl.php @@ -15,13 +15,8 @@ load_class( 'items/model/_itemtag.class.php', 'ItemTag' ); -/** - * @var User - */ -global $current_User; - // Check minimum permission: -$current_User->check_perm( 'options', 'view', true ); +check_user_perm( 'options', 'view', true ); $AdminUI->set_path( 'site', 'tags' ); @@ -49,14 +44,14 @@ case 'new': // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); $edited_ItemTag = new ItemTag(); break; case 'edit': // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); break; case 'create': @@ -67,7 +62,7 @@ $Session->assert_received_crumb( 'tag' ); // Check that current user has permission to create tags: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // load data from request if( $edited_ItemTag->load_from_Request() ) @@ -90,7 +85,7 @@ $Session->assert_received_crumb( 'tag' ); // Check that current user has permission to edit tags: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure we got an tag_ID: param( 'tag_ID', 'integer', true ); @@ -116,7 +111,7 @@ $Session->assert_received_crumb( 'tag' ); // Check that current user has permission to edit tags: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure we got an tag_ID: param( 'tag_ID', 'integer', true ); @@ -148,7 +143,7 @@ $Session->assert_received_crumb( 'tag' ); // Check that current user has permission to edit tags: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); $item_ID = param( 'item_ID', 'integer', 0, true ); @@ -156,7 +151,7 @@ $edited_Item = & $ItemCache->get_by_ID( $item_ID ); // Check permission based on DB status: - $current_User->check_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item ); + check_user_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item ); $result = $DB->query( 'DELETE FROM T_items__itemtag WHERE itag_itm_ID = '.$DB->quote( $edited_Item->ID ).' @@ -182,7 +177,7 @@ $Session->assert_received_crumb( 'tag' ); // Check that current user has permission to edit tags: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); $old_tag_ID = param( 'old_tag_ID', 'integer', 0, true ); @@ -238,7 +233,7 @@ $Session->assert_received_crumb( 'tag' ); // Check that current user has permission to edit tags: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); $DB->query( 'DELETE T_items__itemtag FROM T_items__itemtag LEFT JOIN T_items__item ON itag_itm_ID = post_ID diff --git a/inc/items/item_types.ctrl.php b/inc/items/item_types.ctrl.php index 85bfe34465a..cbcac3c880d 100644 --- a/inc/items/item_types.ctrl.php +++ b/inc/items/item_types.ctrl.php @@ -21,13 +21,8 @@ */ global $AdminUI; -/** - * @var User - */ -global $current_User; - // Check minimum permission: -$current_User->check_perm( 'options', 'view', true ); +check_user_perm( 'options', 'view', true ); // We should activate toolbar menu items for this controller $activate_collection_toolbar = true; @@ -60,7 +55,7 @@ case 'new': // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); if( ! isset($edited_Itemtype) ) { // We don't have a model to use, start with blank object: @@ -78,7 +73,7 @@ case 'edit': // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure we got an ityp_ID: param( 'ityp_ID', 'integer', true ); @@ -95,7 +90,7 @@ $edited_Itemtype = new ItemType(); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // load data from request if( $edited_Itemtype->load_from_Request() ) @@ -138,7 +133,7 @@ $Session->assert_received_crumb( 'itemtype' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure we got an ityp_ID: param( 'ityp_ID', 'integer', true ); @@ -178,7 +173,7 @@ $Session->assert_received_crumb( 'itemtype' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure we got an ityp_ID: param( 'ityp_ID', 'integer', true ); @@ -238,7 +233,7 @@ $Session->assert_received_crumb( 'itemtype' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); if( $edited_Itemtype ) { // Do only when item type exists in DB @@ -270,7 +265,7 @@ $Session->assert_received_crumb( 'itemtype' ); // Check permission: - $current_User->check_perm( 'blog_properties', 'edit', true, $blog ); + check_user_perm( 'blog_properties', 'edit', true, $blog ); if( $edited_Itemtype ) { // Do only when item type exists in DB: diff --git a/inc/items/items.ctrl.php b/inc/items/items.ctrl.php index 2c29ffe8b2f..c30262cf47b 100644 --- a/inc/items/items.ctrl.php +++ b/inc/items/items.ctrl.php @@ -251,7 +251,7 @@ } // Check perms: - $current_User->check_perm( 'blog_post_statuses', 'edit', true, $Blog->ID ); + check_user_perm( 'blog_post_statuses', 'edit', true, $Blog->ID ); break; case 'make_posts_from_files': @@ -287,7 +287,7 @@ // Get status (includes PERM CHECK): $item_status = param( 'post_status', 'string', $Blog->get_allowed_item_status() ); - $current_User->check_perm( 'blog_post!'.$item_status, 'create', true, $Blog->ID ); + check_user_perm( 'blog_post!'.$item_status, 'create', true, $Blog->ID ); load_class( 'files/model/_filelist.class.php', 'FileList' ); $selected_Filelist = new Filelist( $fm_FileRoot, false ); @@ -327,7 +327,7 @@ // Create a new category from an entered name // Check permissions: - $current_User->check_perm( 'blog_cats', '', true, $blog ); + check_user_perm( 'blog_cats', '', true, $blog ); $ChapterCache = & get_ChapterCache(); $new_Chapter = & $ChapterCache->new_obj( NULL, $blog ); // create new category object @@ -463,7 +463,7 @@ } // Check perm: - $current_User->check_perm( 'blog_post_statuses', 'edit', true, $blog ); + check_user_perm( 'blog_post_statuses', 'edit', true, $blog ); $new_post_creation_result = false; $CommentCache = & get_CommentCache(); @@ -606,7 +606,7 @@ foreach( $selected_items as $selected_item_ID ) { if( ( $selected_Item = & $ItemCache->get_by_ID( $selected_item_ID, false, false ) ) && - $current_User->check_perm( 'item_post!CURSTATUS', 'edit', false, $selected_Item ) ) + check_user_perm( 'item_post!CURSTATUS', 'edit', false, $selected_Item ) ) { // If current User has a permission to edit the selected Item: $selected_Item->set( 'status', $item_status ); if( $selected_Item->dbupdate() ) @@ -682,7 +682,7 @@ foreach( $selected_items as $selected_item_ID ) { if( ( $selected_Item = & $ItemCache->get_by_ID( $selected_item_ID, false, false ) ) && - $current_User->check_perm( 'item_post!CURSTATUS', 'delete', false, $selected_Item ) && + check_user_perm( 'item_post!CURSTATUS', 'delete', false, $selected_Item ) && $selected_Item->dbdelete() ) { // If current User has a permission to delete the selected Item: $items_success++; @@ -747,8 +747,8 @@ foreach( $selected_comments as $selected_comment_ID ) { if( ( $selected_Comment = & $CommentCache->get_by_ID( $selected_comment_ID, false, false ) ) && - $current_User->check_perm( 'comment!CURSTATUS', 'moderate', false, $selected_Comment ) && - $current_User->check_perm( 'comment!'.$comment_status, 'moderate', false, $selected_Comment ) ) + check_user_perm( 'comment!CURSTATUS', 'moderate', false, $selected_Comment ) && + check_user_perm( 'comment!'.$comment_status, 'moderate', false, $selected_Comment ) ) { // If current User has a permission to edit the selected Comment: $selected_Comment->set( 'status', $comment_status ); if( $selected_Comment->dbupdate() ) @@ -827,7 +827,7 @@ { $comment_status = false; if( ( $selected_Comment = & $CommentCache->get_by_ID( $selected_comment_ID, false, false ) ) && - $current_User->check_perm( 'comment!CURSTATUS', 'delete', false, $selected_Comment ) ) + check_user_perm( 'comment!CURSTATUS', 'delete', false, $selected_Comment ) ) { // If current User has a permission to recycle/delete the selected Comment: $comment_status = $selected_Comment->get( 'status' ); if( $selected_Comment->dbdelete( $force_permanent_delete ) ) @@ -918,7 +918,7 @@ foreach( $selected_items as $selected_item_ID ) { if( ( $selected_Item = & $ItemCache->get_by_ID( $selected_item_ID, false, false ) ) && - $current_User->check_perm( 'item_post!CURSTATUS', 'edit', false, $selected_Item ) ) + check_user_perm( 'item_post!CURSTATUS', 'edit', false, $selected_Item ) ) { // If current User has a permission to edit the selected Item: $current_extra_categories = postcats_get_byID( $selected_Item->ID ); if( $cat_type == 'main' ) @@ -1046,7 +1046,7 @@ foreach( $selected_items as $selected_item_ID ) { if( ( $selected_Item = & $ItemCache->get_by_ID( $selected_item_ID, false, false ) ) && - $current_User->check_perm( 'item_post!CURSTATUS', 'edit', false, $selected_Item ) ) + check_user_perm( 'item_post!CURSTATUS', 'edit', false, $selected_Item ) ) { // If current User has a permission to edit the selected Item: if( $renderer_change_type == 'add_renderer' ) { @@ -1268,6 +1268,9 @@ // Load all custom fields: $edited_Item->get_custom_fields_defs(); + // Set parent item ID to find category order + $edited_Item->set( 'parent_item_ID', $edited_Item->ID ); + // Set ID of copied post to 0, because some functions can update current post, e.g. $edited_Item->get( 'excerpt' ) $edited_Item->ID = 0; @@ -1301,7 +1304,7 @@ { // Create Item in different collection: $BlogCache = & get_BlogCache(); $linked_Blog = $BlogCache->get_by_ID( $post_coll_ID, false, false ); - if( ! $current_User->check_perm( 'blog_post_statuses', 'edit', false, $post_coll_ID ) ) + if( ! check_user_perm( 'blog_post_statuses', 'edit', false, $post_coll_ID ) ) { // If current User cannot create an Item in the selected locale collection, // Redirect back to edit Item form: $Messages->add( sprintf( TB_('You don\'t have a permission to create new Item in the collection "%s"!'), $linked_Blog ? $linked_Blog->get( 'name' ) : '#'.$post_coll_ID ) ); @@ -1365,7 +1368,7 @@ // This is somewhat in between new and edit... // Check permission based on DB status: - $current_User->check_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item ); + check_user_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item ); $edited_Item->status = param( 'post_status', 'string', NULL ); // 'published' or 'draft' or ... // We know we can use at least one status, @@ -1415,12 +1418,12 @@ case 'history': // Check permission: - $current_User->check_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item ); + check_user_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item ); break; case 'history_lastseen': // Check permission: - $current_User->check_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item ); + check_user_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item ); $SQL = new SQL( 'Find last not seen revision of the Item #'.$edited_Item->ID.' by current User' ); $SQL->SELECT( 'iver_ID' ); @@ -1445,7 +1448,7 @@ case 'history_details': // Check permission: - $current_User->check_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item ); + check_user_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item ); $Revision = $edited_Item->get_revision( param( 'r', 'string' ) ); @@ -1466,7 +1469,7 @@ case 'history_compare': // Check permission: - if( ! $current_User->check_perm( 'item_post!CURSTATUS', 'edit', false, $edited_Item ) ) + if( ! check_user_perm( 'item_post!CURSTATUS', 'edit', false, $edited_Item ) ) { $Messages->add( TB_('You have no permission to view history for this item.'), 'error' ); header_redirect( $admin_url ); @@ -1645,7 +1648,7 @@ $Session->assert_received_crumb( 'item' ); // Check permission: - $current_User->check_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item ); + check_user_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item ); param( 'r', 'integer', 0 ); @@ -1659,7 +1662,7 @@ case 'edit': // Check permission: - $current_User->check_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item ); + check_user_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item ); // Restrict Item status by Collection access restriction AND by CURRENT USER write perm: $edited_Item->restrict_status(); @@ -1682,7 +1685,7 @@ case 'propose': // Check permission: - $current_User->check_perm( 'blog_item_propose', 'edit', true, $Blog->ID ); + check_user_perm( 'blog_item_propose', 'edit', true, $Blog->ID ); $AdminUI->breadcrumbpath_add( sprintf( /* TRANS: noun */ TB_('Post').' #%s', $edited_Item->ID ), '?ctrl=items&blog='.$Blog->ID.'&p='.$edited_Item->ID ); $AdminUI->breadcrumbpath_add( TB_('Propose change'), '?ctrl=items&action=propose&blog='.$Blog->ID.'&p='.$edited_Item->ID ); @@ -1697,7 +1700,7 @@ $Session->assert_received_crumb( 'item' ); // Get params to skip/force/mark notifications and pings: - if( $current_User->check_perm( 'blog_edit_ts', 'edit', false, $Blog->ID ) ) + if( check_user_perm( 'blog_edit_ts', 'edit', false, $Blog->ID ) ) { // If user has a permission to edit advanced properties of items: param( 'item_members_notified', 'string', NULL ); param( 'item_community_notified', 'string', NULL ); @@ -1725,7 +1728,7 @@ check_cross_posting( $post_category, $post_extracats ); // Check permission on statuses: - $current_User->check_perm( 'cats_post!'.$post_status, 'create', true, $post_extracats ); + check_user_perm( 'cats_post!'.$post_status, 'create', true, $post_extracats ); // Get requested Post Type: $item_typ_ID = param( 'item_typ_ID', 'integer', true /* require input */ ); @@ -1734,6 +1737,9 @@ // Update the folding positions for current user save_fieldset_folding_values( $Blog->ID ); + + // Update the active tab pane for current user + save_active_tab_pane_value( $Blog->ID ); // CREATE NEW POST: load_class( 'items/model/_item.class.php', 'Item' ); @@ -1784,14 +1790,14 @@ if( $result && $action == 'create_link' ) { // If the item has been inserted correctly and we should copy all links from the duplicated item: - if( $current_User->check_perm( 'item_post!CURSTATUS', 'edit', false, $edited_Item ) - && $current_User->check_perm( 'files', 'view', false ) ) + if( check_user_perm( 'item_post!CURSTATUS', 'edit', false, $edited_Item ) + && check_user_perm( 'files', 'view', false ) ) { // Allow this action only if current user has a permission to view the links of new created item: $original_item_ID = param( 'p', 'integer', NULL ); $ItemCache = & get_ItemCache(); if( $original_Item = & $ItemCache->get_by_ID( $original_item_ID, false, false ) ) { // Copy the links only if the requested item is correct: - if( $current_User->check_perm( 'item_post!CURSTATUS', 'view', false, $original_Item ) ) + if( check_user_perm( 'item_post!CURSTATUS', 'view', false, $original_Item ) ) { // Current user must has a permission to view an original item $DB->query( 'INSERT INTO T_links ( link_datecreated, link_datemodified, link_creator_user_ID, link_lastedit_user_ID, link_itm_ID, link_file_ID, link_position, link_order ) @@ -1843,7 +1849,7 @@ // Delete Item from Session delete_session_Item( 0 ); - if( ! $exit_after_save && $current_User->check_perm( 'item_post!CURSTATUS', 'edit', false, $edited_Item ) ) + if( ! $exit_after_save && check_user_perm( 'item_post!CURSTATUS', 'edit', false, $edited_Item ) ) { // We want to continue editing... $tab_switch_params = 'p='.$edited_Item->ID; $action = 'edit'; // It's basically as if we had updated @@ -1907,7 +1913,7 @@ $Session->assert_received_crumb( 'item' ); // Check edit permission: - $current_User->check_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item ); + check_user_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item ); param( 'dest_post_ID', 'integer', true ); @@ -1948,7 +1954,7 @@ $Session->assert_received_crumb( 'item' ); // Check edit permission: - $current_User->check_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item ); + check_user_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item ); param( 'unlink_item_ID', 'integer', true ); @@ -1975,13 +1981,16 @@ $Session->assert_received_crumb( 'item' ); // Check edit permission: - $current_User->check_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item ); + check_user_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item ); // Update the folding positions for current user save_fieldset_folding_values( $Blog->ID ); + + // Update the active tab pane for current user + save_active_tab_pane_value( $Blog->ID ); // Get params to skip/force/mark notifications and pings: - if( $current_User->check_perm( 'blog_edit_ts', 'edit', false, $Blog->ID ) ) + if( check_user_perm( 'blog_edit_ts', 'edit', false, $Blog->ID ) ) { // If user has a permission to edit advanced properties of items: param( 'item_members_notified', 'string', NULL ); param( 'item_community_notified', 'string', NULL ); @@ -2033,7 +2042,7 @@ foreach( $prev_extra_cat_IDs as $cat ) { $cat_blog = get_catblog( $cat ); - if( ! $current_User->check_perm( 'blog_admin', '', false, $cat_blog ) ) + if( ! check_user_perm( 'blog_admin', '', false, $cat_blog ) ) { $Chapter = $ChapterCache->get_by_ID( $cat ); $off_limit_cats[$cat] = $Chapter; @@ -2219,7 +2228,7 @@ unset( $edited_Item->ItemType ); // Check edit permission: - $current_User->check_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item ); + check_user_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item ); set_session_Item( $edited_Item ); @@ -2269,8 +2278,8 @@ param( 'cat_ID', 'integer', NULL ); // Check edit permission: - $current_User->check_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item ); - $current_User->check_perm( 'item_post!'.$status, 'edit', true, $edited_Item ); + check_user_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item ); + check_user_perm( 'item_post!'.$status, 'edit', true, $edited_Item ); // Set new post type $edited_Item->set( 'status', $status ); @@ -2326,7 +2335,7 @@ while ( $Item = & $ItemList->get_item () ) { // check user permission - $current_User->check_perm( 'item_post!CURSTATUS', 'edit', true, $Item ); + check_user_perm( 'item_post!CURSTATUS', 'edit', true, $Item ); // Not allow html content on post titles $title = param ( 'mass_title_' . $Item->ID, 'htmlspecialchars', NULL ); @@ -2380,13 +2389,13 @@ // Check permissions: /* TODO: Check extra categories!!! */ - $current_User->check_perm( 'item_post!'.$post_status, 'edit', true, $edited_Item ); + check_user_perm( 'item_post!'.$post_status, 'edit', true, $edited_Item ); $edited_Item->set( 'status', $post_status ); if( $action == 'publish_now' ) { // Update post dates - $current_User->check_perm( 'blog_edit_ts', 'edit', true, $Blog->ID ); + check_user_perm( 'blog_edit_ts', 'edit', true, $Blog->ID ); // fp> TODO: remove seconds ONLY if date is in the future $edited_Item->set( 'datestart', remove_seconds($localtimenow) ); $edited_Item->set( 'datemodified', date('Y-m-d H:i:s', $localtimenow) ); @@ -2403,7 +2412,7 @@ } // Get params to skip/force/mark notifications and pings: - if( $current_User->check_perm( 'blog_edit_ts', 'edit', false, $Blog->ID ) ) + if( check_user_perm( 'blog_edit_ts', 'edit', false, $Blog->ID ) ) { // If user has a permission to edit advanced properties of items: param( 'item_members_notified', 'string', NULL ); param( 'item_community_notified', 'string', NULL ); @@ -2475,7 +2484,7 @@ $post_status = param( 'post_status', 'string', true ); // Check permissions: - $current_User->check_perm( 'item_post!'.$post_status, 'moderate', true, $edited_Item ); + check_user_perm( 'item_post!'.$post_status, 'moderate', true, $edited_Item ); $edited_Item->set( 'status', $post_status ); @@ -2495,7 +2504,7 @@ $post_status = 'deprecated'; // Check permissions: /* TODO: Check extra categories!!! */ - $current_User->check_perm( 'item_post!'.$post_status, 'edit', true, $edited_Item ); + check_user_perm( 'item_post!'.$post_status, 'edit', true, $edited_Item ); $edited_Item->set( 'status', $post_status ); $edited_Item->set( 'datemodified', date('Y-m-d H:i:s',$localtimenow) ); @@ -2520,7 +2529,7 @@ $Session->assert_received_crumb( 'item' ); // Check permission: - $current_User->check_perm( 'blog_del_post', '', true, $blog ); + check_user_perm( 'blog_del_post', '', true, $blog ); // fp> TODO: non javascript confirmation // $AdminUI->title = TB_('Deleting post...'); @@ -2569,7 +2578,7 @@ $Session->assert_received_crumb( 'item' ); // Check edit permission: - $current_User->check_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item ); + check_user_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item ); $dest_post_ID = param( 'dest_post_ID', 'integer', true ); @@ -2690,7 +2699,7 @@ $Session->assert_received_crumb( 'item' ); // Check edit permission: - $current_User->check_perm( 'blog_item_propose', 'edit', true, $Blog->ID ); + check_user_perm( 'blog_item_propose', 'edit', true, $Blog->ID ); // Check if current User can create a new proposed change: $edited_Item->can_propose_change( true ); @@ -2698,7 +2707,7 @@ if( $edited_Item->create_proposed_change() ) { // If new proposed changes has been inserted in DB successfully: $Messages->add( TB_('New proposed change has been recorded.'), 'success' ); - if( $current_User->check_perm( 'item_post!CURSTATUS', 'edit', false, $edited_Item ) ) + if( check_user_perm( 'item_post!CURSTATUS', 'edit', false, $edited_Item ) ) { // Redirect to item history page with new poroposed change if current User has a permisson: header_redirect( $admin_url.'?ctrl=items&action=history&p='.$edited_Item->ID ); } @@ -2721,7 +2730,7 @@ $Session->assert_received_crumb( 'item' ); // Check edit permission: - $current_User->check_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item ); + check_user_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item ); // Try to get a proposed change by requested ID: $Revision = $edited_Item->get_revision( param( 'r', 'string' ) ); @@ -2763,7 +2772,7 @@ */ function init_list_mode() { - global $tab, $tab_type, $Collection, $Blog, $UserSettings, $ItemList, $AdminUI, $current_User; + global $tab, $tab_type, $Collection, $Blog, $UserSettings, $ItemList, $AdminUI; // set default itemslist param prefix $items_list_param_prefix = 'items_'; @@ -2786,7 +2795,7 @@ function init_list_mode() } } - if( $tab == 'tracker' && ( ! $Blog->get_setting( 'use_workflow' ) || ! $current_User->check_perm( 'blog_can_be_assignee', 'edit', false, $Blog->ID ) ) ) + if( $tab == 'tracker' && ( ! $Blog->get_setting( 'use_workflow' ) || ! check_user_perm( 'blog_can_be_assignee', 'edit', false, $Blog->ID ) ) ) { // Display workflow view only if it is enabled global $Messages; $Messages->add( TB_('Workflow feature has not been enabled for this collection.'), 'note' ); @@ -2834,7 +2843,7 @@ function init_list_mode() require_js_helper( 'colorbox' ); // require clipboardjs - require_js( '#clipboardjs#' ); + require_js_async( '#clipboardjs#' ); $AdminUI->breadcrumbpath_add( TB_('All'), '?ctrl=items&blog=$blog$&tab=full&filter=restore' ); break; @@ -2874,7 +2883,7 @@ function init_list_mode() $AdminUI->breadcrumbpath_add( TB_( $tab_type ), '?ctrl=items&blog=$blog$&tab='.$tab.'&tab_type='.urlencode( $tab_type ).'&filter=restore' ); // JS to edit an order of items from list view: - require_js( 'jquery/jquery.jeditable.js', 'rsc_url' ); + require_js_defer( 'customized:jquery/jeditable/jquery.jeditable.js', 'rsc_url' ); break; case 'tracker': @@ -2887,7 +2896,7 @@ function init_list_mode() $AdminUI->set_page_manual_link( 'workflow-features' ); // JS to edit priority of items from list view - require_js( 'jquery/jquery.jeditable.js', 'rsc_url' ); + require_js_defer( 'customized:jquery/jeditable/jquery.jeditable.js', 'rsc_url' ); break; default: @@ -2928,7 +2937,7 @@ function init_list_mode() if( ! blog_has_cats( $blog ) ) { $error_message = TB_('Since this blog has no categories, you cannot post into it.'); - if( $current_User->check_perm( 'blog_cats', 'edit', false, $blog ) ) + if( check_user_perm( 'blog_cats', 'edit', false, $blog ) ) { // If current user has a permission to create a category global $admin_url; $error_message .= ' '.sprintf( TB_('You must create categories first.'), 'href="'.$admin_url.'?ctrl=chapters&blog='.$blog.'"'); @@ -3004,7 +3013,7 @@ function init_list_mode() ) ); } - if( $current_User->check_perm( 'item_post!CURSTATUS', 'edit', false, $edited_Item ) ) + if( check_user_perm( 'item_post!CURSTATUS', 'edit', false, $edited_Item ) ) { // If user has a permission to merge the edited Item: $AdminUI->global_icon( TB_('Merge with...'), 'merge', '#', ' '.TB_('Merge with...'), 4, 3, array( @@ -3013,7 +3022,7 @@ function init_list_mode() ) ); } - if( $current_User->check_perm( 'item_post!CURSTATUS', 'delete', false, $edited_Item ) ) + if( check_user_perm( 'item_post!CURSTATUS', 'delete', false, $edited_Item ) ) { // User has permissions to delete this post $AdminUI->global_icon( TB_('Delete this post'), 'delete', $admin_url.'?ctrl=items&action=delete&post_ID='.$edited_Item->ID.'&'.url_crumb('item'), ' '.TB_('Delete'), 4, 3, array( @@ -3056,7 +3065,7 @@ function init_list_mode() } } - if( $action != 'propose' && $Blog->get_setting( 'in_skin_editing' ) && ( $current_User->check_perm( 'blog_post!published', 'edit', false, $Blog->ID ) || get_param( 'p' ) > 0 ) ) + if( $action != 'propose' && $Blog->get_setting( 'in_skin_editing' ) && ( check_user_perm( 'blog_post!published', 'edit', false, $Blog->ID ) || get_param( 'p' ) > 0 ) ) { // Show 'In skin' link if Blog setting 'In-skin editing' is ON and User has a permission to publish item in this blog $mode_inskin_url = url_add_param( $Blog->get( 'url' ), 'disp=edit&'.$tab_switch_params ); $mode_inskin_action = get_htsrv_url().'item_edit.php'; @@ -3076,7 +3085,7 @@ function init_list_mode() if( in_array( $action, array( 'history', 'history_details', 'history_compare' ) ) ) { // History tabs: - if( $current_User->check_perm( 'item_post!CURSTATUS', 'delete', false, $edited_Item ) ) + if( check_user_perm( 'item_post!CURSTATUS', 'delete', false, $edited_Item ) ) { // User has permissions to edit this Item: $AdminUI->global_icon( TB_('Edit current version'), 'edit', $admin_url.'?ctrl=items&action=edit&p='.$edited_Item->ID, TB_('Edit current version'), 4, 3, array( 'style' => 'margin-right:3ex' ) ); } @@ -3103,7 +3112,7 @@ function init_list_mode() if( ! blog_has_cats( $blog ) ) { $error_message = TB_('Since this blog has no categories, you cannot post into it.'); - if( $current_User->check_perm( 'blog_cats', 'edit', false, $blog ) ) + if( check_user_perm( 'blog_cats', 'edit', false, $blog ) ) { // If current user has a permission to create a category global $admin_url; $error_message .= ' '.sprintf( TB_('You must create categories first.'), 'href="'.$admin_url.'?ctrl=chapters&blog='.$blog.'"'); @@ -3212,8 +3221,6 @@ function init_list_mode() init_autocomplete_usernames_js(); // Require colorbox js: require_js_helper( 'colorbox' ); - // Init JS to quick upload several files: - init_fileuploader_js(); } if( in_array( $action, array( 'new', 'new_version', 'copy', 'create_edit', 'create_link', 'create', 'create_publish', 'edit', 'update_edit', 'update', 'update_publish', 'extract_tags' ) ) ) @@ -3519,7 +3526,7 @@ function init_list_mode() if( $Blog->get( 'notes' ) ) { $edit_link = ''; - if( $current_User->check_perm( 'blog_properties', 'edit', false, $blog ) ) + if( check_user_perm( 'blog_properties', 'edit', false, $blog ) ) { $edit_link = action_icon( TB_('Edit').'...', 'edit_button', $admin_url.'?ctrl=coll_settings&tab=general&blog='.$Blog->ID, ' '.TB_('Edit').'...', 3, 4, array( 'class' => 'btn btn-default btn-sm' ) ); } diff --git a/inc/items/model/_checklistline.class.php b/inc/items/model/_checklistline.class.php new file mode 100644 index 00000000000..dd286f20be7 --- /dev/null +++ b/inc/items/model/_checklistline.class.php @@ -0,0 +1,125 @@ +ID = $db_row->check_ID; + $this->item_ID = $db_row->check_item_ID; + $this->checked = $db_row->check_checked; + $this->label = $db_row->check_label; + $this->order = $db_row->check_order; + } + } + + + /** + * Get the Item this comment relates to + * + * @return Item + */ + function & get_Item() + { + if( ! isset( $this->Item ) ) + { + $ItemCache = & get_ItemCache(); + $this->Item = & $ItemCache->get_by_ID( $this->item_ID, false, false ); + } + + return $this->Item; + } + + + /** + * Set Item this comment relates to + * @param Item + */ + function set_Item( & $Item ) + { + $this->Item = & $Item; + parent::set_param( 'item_ID', 'number', $Item->ID ); + } + + + /** + * Insert object into DB based on previously recorded changes. + * + * Note: DataObject does not require a matching *Cache object. + * Therefore it will not try to update the Cache. + * If something like that was needed, sth like *Cache->add() should be called. + * ATTENTION: Any dbinsert should typically be followed by a 303 redirect. Updating the Cache before redirect is generally not needed. + * + * @return boolean true on success + */ + function dbinsert() + { + global $DB; + + if( empty( $this->order ) ) + { + $SQL = new SQL('Get max'); + $SQL->SELECT( 'MAX(check_order)' ); + $SQL->FROM( 'T_items__checklist_lines' ); + $SQL->WHERE( 'check_item_ID ='.$DB->quote( $this->item_ID ) ); + $max_order = intval( $DB->get_var( $SQL ) ) + 1; + $this->set( 'order', $max_order ); + } + + $r = parent::dbinsert(); + + return $r; + } +} +?> diff --git a/inc/items/model/_item.class.php b/inc/items/model/_item.class.php index b95e138378c..9ccc8fb2169 100644 --- a/inc/items/model/_item.class.php +++ b/inc/items/model/_item.class.php @@ -747,7 +747,7 @@ function lastedit_user( $params = array() ) */ function load_from_Request( $editing = false, $creating = false ) { - global $default_locale, $current_User, $localtimenow, $Blog, $Plugins; + global $default_locale, $localtimenow, $Blog, $Plugins; global $item_typ_ID; // LOCALE: @@ -824,7 +824,7 @@ function load_from_Request( $editing = false, $creating = false ) } // Single/page view: - if( is_logged_in() && $current_User->check_perm( 'blog_edit_ts', 'edit', false, $Blog->ID ) && + if( check_user_perm( 'blog_edit_ts', 'edit', false, $Blog->ID ) && ( $single_view = param( 'post_single_view', 'string', NULL ) ) !== NULL ) { // If user has a permission to edit advanced properties of items: if( $this->get( 'status' ) == 'redirected' ) @@ -847,9 +847,8 @@ function load_from_Request( $editing = false, $creating = false ) // ISSUE DATE / TIMESTAMP: $this->load_Blog(); - if( is_logged_in() && - $current_User->check_perm( 'admin', 'restricted' ) && - $current_User->check_perm( 'blog_edit_ts', 'edit', false, $this->Blog->ID ) ) + if( check_user_perm( 'admin', 'restricted' ) && + check_user_perm( 'blog_edit_ts', 'edit', false, $this->Blog->ID ) ) { // Allow to update timestamp fields only if user has a permission to edit such fields // and also if user has an access to back-office $item_dateset = param( 'item_dateset', 'integer', NULL ); @@ -955,7 +954,7 @@ function load_from_Request( $editing = false, $creating = false ) $this->load_workflow_from_Request(); // FEATURED checkbox: - if( is_logged_in() && $current_User->check_perm( 'blog_edit_ts', 'edit', false, $Blog->ID ) ) + if( check_user_perm( 'blog_edit_ts', 'edit', false, $Blog->ID ) ) { // If user has a permission to edit advanced properties of items: $this->set( 'featured', param( 'item_featured', 'integer', 0 ), false ); } @@ -980,7 +979,7 @@ function load_from_Request( $editing = false, $creating = false ) } // Goal ID: - if( is_logged_in() && $current_User->check_perm( 'blog_edit_ts', 'edit', false, $Blog->ID ) ) + if( check_user_perm( 'blog_edit_ts', 'edit', false, $Blog->ID ) ) { // If user has a permission to edit advanced properties of items: $goal_ID = param( 'goal_ID', 'integer', NULL ); if( $goal_ID !== NULL ) @@ -998,7 +997,7 @@ function load_from_Request( $editing = false, $creating = false ) // OWNER: $this->creator_user_login = param( 'item_owner_login', 'string', NULL ); - if( is_logged_in() && $current_User->check_perm( 'users', 'edit' ) && param( 'item_owner_login_displayed', 'string', NULL ) !== NULL ) + if( check_user_perm( 'users', 'edit' ) && param( 'item_owner_login_displayed', 'string', NULL ) !== NULL ) { // only admins can change the owner.. if( param_check_not_empty( 'item_owner_login', T_('Please enter valid owner login.') ) ) { // If valid user login is entered: @@ -1079,7 +1078,7 @@ function load_from_Request( $editing = false, $creating = false ) } // EXPIRY DELAY: - if( is_logged_in() && $current_User->check_perm( 'blog_edit_ts', 'edit', false, $Blog->ID ) ) + if( check_user_perm( 'blog_edit_ts', 'edit', false, $Blog->ID ) ) { // If user has a permission to edit advanced properties of items: $expiry_delay = param_duration( 'expiry_delay' ); if( empty( $expiry_delay ) ) @@ -1262,8 +1261,6 @@ function load_from_Request( $editing = false, $creating = false ) */ function load_workflow_from_Request() { - global $current_User; - // Get Item's Collection for settings and permissions validation: $item_Blog = & $this->get_Blog(); @@ -1728,7 +1725,7 @@ function can_see_comments( $display = false ) */ function can_comment( $before_error = '

    ', $after_error = '

    ', $non_published_msg = '#', $closed_msg = '#', $section_title = '', $params = array(), $comment_type = 'comment' ) { - global $current_User, $disp; + global $disp; if( $comment_type == 'meta' && $this->can_meta_comment() ) { // Meta comment are always allowed! @@ -1792,7 +1789,7 @@ function can_comment( $before_error = '

    ', $after_error = '

    ', $no return false; } - if( is_logged_in() && ( $this->Blog->get( 'advanced_perms' ) ) && !$current_User->check_perm( 'blog_comment_statuses', 'create', false, $this->Blog->ID ) ) + if( is_logged_in() && ( $this->Blog->get( 'advanced_perms' ) ) && ! check_user_perm( 'blog_comment_statuses', 'create', false, $this->Blog->ID ) ) { // User doesn't have permission to create comments and advanced perms are enabled if( $display ) { @@ -1844,9 +1841,7 @@ function can_see_meta_comments() } } - global $current_User; - - return $current_User->check_perm( 'meta_comment', 'view', false, $this->get_blog_ID() ); + return check_user_perm( 'meta_comment', 'view', false, $this->get_blog_ID() ); } @@ -1857,14 +1852,7 @@ function can_see_meta_comments() */ function can_meta_comment() { - if( ! is_logged_in() ) - { // User must be logged in - return false; - } - - global $current_User; - - return $current_User->check_perm( 'meta_comment', 'add', false, $this->get_blog_ID() ); + return check_user_perm( 'meta_comment', 'add', false, $this->get_blog_ID() ); } @@ -1878,8 +1866,6 @@ function can_meta_comment() */ function check_blog_settings( $settings_name, $settings_object = NULL ) { - global $current_User; - $this->load_Blog(); if( ( $settings_name == 'allow_attachments' ) @@ -1900,9 +1886,9 @@ function check_blog_settings( $settings_name, $settings_object = NULL ) case 'registered': return is_logged_in( false ); case 'member': - return (is_logged_in( false ) && $current_User->check_perm( 'blog_ismember', 'view', false, $this->get_blog_ID() ) ); + return check_user_perm( 'blog_ismember', 'view', false, $this->get_blog_ID(), false ); case 'moderator': - return (is_logged_in( false ) && $current_User->check_perm( 'blog_comments', 'edit', false, $this->get_blog_ID() ) ); + return check_user_perm( 'blog_comments', 'edit', false, $this->get_blog_ID(), false ); default: debug_die( 'Invalid blog '.$settings_name.' settings!' ); } @@ -1921,7 +1907,7 @@ function check_blog_settings( $settings_name, $settings_object = NULL ) */ function can_attach( $link_tmp_ID = false, $comment_type = 'comment' ) { - global $Settings, $current_User; + global $Settings; $attachments_quota_is_full = false; if( is_logged_in() ) @@ -1936,7 +1922,7 @@ function can_attach( $link_tmp_ID = false, $comment_type = 'comment' ) $max_attachments = (int)$this->Blog->get_setting( 'max_attachments' ); if( $max_attachments > 0 ) { // Check attachments quota only when Blog setting "Max # of attachments" is defined - global $DB, $current_User, $Session; + global $DB, $Session; // Get a number of attachments for current user on this post $link_tmp_ID = false; @@ -2362,16 +2348,29 @@ function excerpt( $params = array() ) if( ! empty( $r ) ) { echo $params['before']; + + if( isset( $params['max_words'] ) ) + { + // to stop displaying double hellip + $params['avoid_end_hellip'] = true; + + echo excerpt_words( $r, $params['max_words'], $params ); + } + else + { + echo $r; + } - echo $r; - - $this->permanent_link( array( - 'before' => $params['excerpt_before_more'], - 'after' => $params['excerpt_after_more'], - 'text' => $params['excerpt_more_text'], - 'title' => '#', - 'class' => $params['excerpt_more_class'], - ) ); + if( ! isset( $params['excerpt_no_more_link'] ) ) + { + $this->permanent_link( array( + 'before' => $params['excerpt_before_more'], + 'after' => $params['excerpt_after_more'], + 'text' => $params['excerpt_more_text'], + 'title' => '#', + 'class' => $params['excerpt_more_class'], + ) ); + } echo $params['after']; } @@ -2434,21 +2433,19 @@ function get_content_page( $page = NULL, $format = 'htmlbody' ) // Make sure, the pages are split up: $this->split_pages( $format ); + $content_page = ''; + if( $preview && $this->pages > 1 && ! $this->ID ) { // This is a preview of an unsaved multipage item - $preview_content = ''; - foreach( $this->content_pages[$format] as $page => $page_content ) { if( $page !== 0 ) { - $preview_content .= 'Page '.( $page + 1 ).''; + $content_page .= 'Page '.( $page + 1 ).''; } - $preview_content .= $page_content; + $content_page .= $page_content; } - - return $preview_content; } else { @@ -2462,8 +2459,15 @@ function get_content_page( $page = NULL, $format = 'htmlbody' ) $page = $this->pages; } - return $this->content_pages[$format][$page-1]; + $content_page = $this->content_pages[$format][$page-1]; } + + if( ! check_user_perm( 'item_post!CURSTATUS', 'edit', false, $this ) ) + { // Clean up rendering errors from content if current User has no permission to edit this Item: + $content_page = clear_rendering_errors( $content_page ); + } + + return $content_page; } @@ -3107,7 +3111,7 @@ function get_custom_field_formatted( $field_name, $params = array() ) } else { // Display an error if Link is not found in DB: - $custom_field_value = ''.T_('Invalid link ID:').' '.$custom_field_value.''; + $custom_field_value = get_rendering_error( T_('Invalid link ID:').' '.$custom_field_value, 'span' ); } break; @@ -3164,7 +3168,8 @@ function get_custom_field_formatted( $field_name, $params = array() ) if( isset( $link_fallbacks[ $custom_field['link'] ] ) ) { $fallback_count = count( $link_fallbacks[ $custom_field['link'] ] ); - $link_class_attr = empty( $custom_field['link_class'] ) ? '' : ' class="'.format_to_output( $custom_field['link_class'], 'htmlattr' ).'"'; + $link_class = trim( $custom_field['link_class'] ); + $link_class_attr = ( $link_class === '' ? '' : ' class="'.format_to_output( $link_class, 'htmlattr' ).'"' ); $nofollow_attr = $custom_field['link_nofollow'] ? ' rel="nofollow"' : ''; foreach( $link_fallbacks[ $custom_field['link'] ] as $l => $link_fallback ) { @@ -3188,7 +3193,7 @@ function get_custom_field_formatted( $field_name, $params = array() ) $Item->ID != $this->ID || $fallback_count == $l + 1 ) { // Use permalink if it is not last point and we don't view this current post: - $custom_field_value = $this->get_permanent_link( $custom_field_value, '#', $custom_field['link_class'], '', '', NULL, array(), array( 'nofollow' => $custom_field['link_nofollow'] ) ); + $custom_field_value = $this->get_permanent_link( $custom_field_value, '#', $link_class, '', '', NULL, array(), array( 'nofollow' => $custom_field['link_nofollow'] ) ); break 2; } // else fallback to other points: @@ -3211,7 +3216,17 @@ function get_custom_field_formatted( $field_name, $params = array() ) // Use value of url fields as URL to the link: if( ! empty( $orig_custom_field_value ) ) { // Format URL to link only with not empty URL otherwise display URL as simple text if special text is defined in format for empty URL: - $custom_field_value = ''.$custom_field_value.''; + $url_link_class = $custom_field['link_class']; + if( $custom_field_value == $orig_custom_field_value ) + { // Use word-break style only when original URL is used for link text because URL may contains very long single word: + $url_link_class .= ' linebreak'; + } + $custom_field_value = '' + .$custom_field_value + .''; } break 2; } @@ -3350,7 +3365,7 @@ public function custom( $params ) $field_name = $params['field']; if( ! isset( $custom_fields[ $field_name ] ) ) { // Custom field with this index doesn't exist - echo ''.sprintf( T_('The custom field %s does not exist!'), ''.$field_name.'' ).''; + display_rendering_error( sprintf( T_('The custom field %s does not exist!'), ''.$field_name.'' ), 'span' ); return; } @@ -3427,71 +3442,79 @@ function render_inline_tags( $content, $params = array() ) { $params = array_merge( array( 'check_code_block' => true, // TRUE to find inline tags only outside of codeblocks - 'render_content_blocks' => true, - 'render_inline_files' => true, - 'render_links' => true, - 'render_custom_fields' => true, - 'render_other_item' => true, - 'render_collection' => true, - 'render_inline_widgets' => true, - 'render_block_widgets' => true, - 'render_switchable_blocks' => true, - 'render_templates' => true, + // render_content_blocks(): + 'render_tag_include' => true, + 'render_tag_cblock' => true, + // render_inline_widgets(): + 'render_tag_item_subscribe' => true, + 'render_tag_item_emailcapture' => true, + 'render_tag_item_compare' => true, + 'render_tag_item_fields' => true, + // render_block_widgets(): + 'render_tag_switcher' => true, + // render_inline_files(): + 'render_tag_image' => true, + 'render_tag_file' => true, + 'render_tag_inline' => true, + 'render_tag_video' => true, + 'render_tag_audio' => true, + 'render_tag_thumbnail' => true, + 'render_tag_folder' => true, + // render_link_data(): + 'render_tag_item_link' => true, + // render_custom_fields(): + 'render_tag_field' => true, + // render_other_item_data(): + 'render_tag_item_field' => true, + 'render_tag_item_titlelink' => true, + 'render_tag_item_url' => true, + // render_collection_data(): + 'render_tag_coll_name' => true, + 'render_tag_coll_shortname' => true, + // render_switchable_blocks(): + 'render_tag_switchable_div' => true, + // render_templates(): + 'render_tag_template' => true, ), $params ); // Remove block level short tags inside

    blocks and move them before the paragraph: $content = move_short_tags( $content ); - if( $params['render_content_blocks'] ) - { // Render Content block tags like [include:123], [include:item-slug], [cblock:123], [cblock:item-slug]: - $content = $this->render_content_blocks( $content, $params ); - } + // Render Content block tags like [include:123], [include:item-slug], [cblock:123], [cblock:item-slug]: + $content = $this->render_content_blocks( $content, $params ); - if( $params['render_inline_widgets'] ) - { // Render widget tags (subscribe, emailcapture, compare, fields): - $content = $this->render_inline_widgets( $content, $params ); - } + // Render widget tags (subscribe, emailcapture, compare, fields): + $content = $this->render_inline_widgets( $content, $params ); - if( $params['render_block_widgets'] ) - { // Render widget tags (switcher): - $content = $this->render_block_widgets( $content, $params ); - } + // Render widget tags (switcher): + $content = $this->render_block_widgets( $content, $params ); - if( $params['render_inline_files'] ) - { // Render inline file tags like [image:123:caption] or [file:123:caption]: - $content = render_inline_files( $content, $this, array_merge( $params, array( - 'clear_paragraph' => false, // Don't clear paragraph twice - ) ) ); - } + // Render inline file tags like [image:123:caption] or [file:123:caption]: + $content = render_inline_files( $content, $this, array_merge( $params, array( + 'clear_paragraph' => false, // Don't clear paragraph twice + ) ) ); - if( $params['render_links'] ) - { // Render Collection Data [link:url_field], [link:url_field]title[/link] and etc.: - $content = $this->render_link_data( $content, $params ); - } + // Render Collection Data [link:url_field], [link:url_field]title[/link] and etc.: + $content = $this->render_link_data( $content, $params ); - if( $params['render_custom_fields'] ) - { // Render single value of Custom Fields [field:first_string_field]: - $content = $this->render_custom_fields( $content, $params ); - } + // Render single value of Custom Fields [field:first_string_field]: + $content = $this->render_custom_fields( $content, $params ); - if( $params['render_other_item'] ) - { // Render parent/other item data [parent:titlelink], [parent:url], [parent:field:first_string_field], [item:123:titlelink], [item:slug:titlelink] and etc.: - $content = $this->render_other_item_data( $content, $params ); - } + // Render parent/other item data [parent:titlelink], [parent:url], [parent:field:first_string_field], [item:123:titlelink], [item:slug:titlelink] and etc.: + $content = $this->render_other_item_data( $content, $params ); - if( $params['render_collection'] ) - { // Render Collection Data [coll:name], [coll:shortname]: - $content = $this->render_collection_data( $content, $params ); - } + // Render Collection Data [coll:name], [coll:shortname]: + $content = $this->render_collection_data( $content, $params ); - if( $params['render_switchable_blocks'] ) - { // Render switchable block tags like [div::view=detailed]Multiline Content Text[/div]: - $content = $this->render_switchable_blocks( $content, $params ); - } + // Render switchable block tags like [div::view=detailed]Multiline Content Text[/div]: + $content = $this->render_switchable_blocks( $content, $params ); - if( $params['render_templates'] ) - { // Render template tags like [template:template_code|param1=value1|param2=value2]: - $content = $this->render_templates( $content, $params ); + // Render template tags like [template:template_code|param1=value1|param2=value2]: + $content = $this->render_templates( $content, $params ); + + if( ! check_user_perm( 'item_post!CURSTATUS', 'edit', false, $this ) ) + { // Clean up rendering errors from content if current User has no permission to edit this Item: + $content = clear_rendering_errors( $content ); } return $content; @@ -3509,6 +3532,36 @@ function render_inline_widgets( $content, $params ) { global $Settings; + $params = array_merge( array( + 'render_tag_item_subscribe' => true, + 'render_tag_item_emailcapture' => true, + 'render_tag_item_compare' => true, + 'render_tag_item_fields' => true, + ), $params ); + + $render_tags = array(); + if( $params['render_tag_item_subscribe'] ) + { // Render short tag [subscribe:] + $render_tags[] = 'subscribe'; + } + if( $params['render_tag_item_emailcapture'] ) + { // Render short tag [emailcapture:] + $render_tags[] = 'emailcapture'; + } + if( $params['render_tag_item_compare'] ) + { // Render short tag [compare:] + $render_tags[] = 'compare'; + } + if( $params['render_tag_item_fields'] ) + { // Render short tag [fields:] + $render_tags[] = 'fields'; + } + + if( empty( $render_tags ) ) + { // No tags for rendering: + return $content; + } + load_funcs( 'skins/_skin.funcs.php' ); if( isset( $params['check_code_block'] ) && $params['check_code_block'] && ( ( stristr( $content, 'render_collection_data() on everything outside code/pre: @@ -3520,7 +3573,7 @@ function render_inline_widgets( $content, $params ) } // Find all matches with tags of widgets: - preg_match_all( '/\[(parent:|item:[^:\]]+:)?(subscribe|emailcapture|compare|fields):?([^\]]*)\]/i', $content, $tags ); + preg_match_all( '/\[(parent:|item:[^:\]]+:)?('.implode( '|', $render_tags ).'):?([^\]]*)\]/i', $content, $tags ); if( count( $tags[0] ) > 0 ) { // If at least one widget tag is found in content: @@ -3673,7 +3726,7 @@ function render_inline_widgets( $content, $params ) { // Use parent item: if( ! ( $widget_Item = & $this->get_parent_Item() ) ) { // Display error message if parent doesn't exist: - $widget_html = ''.T_('This Item has no parent.').''; + $widget_html = get_rendering_error( T_('This Item has no parent.'), 'span' ); break; } $widget_item_ID = $widget_Item->ID; @@ -3686,7 +3739,7 @@ function render_inline_widgets( $content, $params ) if( ! ( $widget_item_data_is_number && $widget_Item = & $ItemCache->get_by_ID( $widget_item_ID_slug, false, false ) ) && ! ( ! $widget_item_data_is_number && $widget_Item = & $ItemCache->get_by_urltitle( $widget_item_ID_slug, false, false ) ) ) { // Display error message if other item is not found by ID and slug: - $widget_html = ''.sprintf( T_('The Item %s doesn\'t exist.'), ''.$widget_item_ID_slug.'' ).''; + $widget_html = get_rendering_error( sprintf( T_('The Item %s doesn\'t exist.'), ''.$widget_item_ID_slug.'' ), 'span' ); break; } $widget_item_ID = $widget_Item->ID; @@ -3700,7 +3753,7 @@ function render_inline_widgets( $content, $params ) $custom_fields = $widget_Item->get_custom_fields_defs(); if( ! $custom_fields ) { // Fields don't exist for this Item: - $widget_html = ''.T_('The Item has no custom fields.').''; + $widget_html = get_rendering_error( T_('The Item has no custom fields.'), 'span' ); break; } @@ -3746,6 +3799,15 @@ function render_block_widgets( $content, $params ) { global $Settings; + $params = array_merge( array( + 'render_tag_switcher' => true, + ), $params ); + + if( ! $params['render_tag_switcher'] ) + { // No tags for rendering: + return $content; + } + load_funcs( 'skins/_skin.funcs.php' ); if( isset( $params['check_code_block'] ) && $params['check_code_block'] && ( ( stristr( $content, 'render_collection_data() on everything outside code/pre: @@ -3774,7 +3836,7 @@ function render_block_widgets( $content, $params ) // Widget "Param Switcher":s if( ! isset( $tag_params[0] ) || $tag_params[0] === '' ) { // Skip wrong configured tag: - $widget_html = ''.T_('Param code must be defined for switcher tag!').''; + $widget_html = get_rendering_error( T_('Param code must be defined for switcher tag!'), 'span' ); break; } @@ -3791,7 +3853,7 @@ function render_block_widgets( $content, $params ) } if( empty( $widget_buttons ) ) { // Don't try to render widget without buttons: - $widget_html = ''.T_('At least one button must be defined for switcher tag!').''; + $widget_html = get_rendering_error( T_('At least one button must be defined for switcher tag!'), 'span' ); break; } @@ -3836,6 +3898,15 @@ function render_block_widgets( $content, $params ) */ function render_custom_fields( $content, $params = array() ) { + $params = array_merge( array( + 'render_tag_field' => true, + ), $params ); + + if( ! $params['render_tag_field'] ) + { // No tags for rendering: + return $content; + } + if( isset( $params['check_code_block'] ) && $params['check_code_block'] && ( ( stristr( $content, 'render_custom_fields() on everything outside code/pre: $params['check_code_block'] = false; @@ -3855,7 +3926,7 @@ function render_custom_fields( $content, $params = array() ) $field_value = $this->get_custom_field_formatted( $field_name, $params ); if( $field_value === false ) { // Wrong field request, display error: - $content = str_replace( $source_tag, ''.sprintf( T_('The field "%s" does not exist.'), $field_name ).'', $content ); + $content = str_replace( $source_tag, get_rendering_error( sprintf( T_('The field "%s" does not exist.'), $field_name ), 'span' ), $content ); } else { // Display field value: @@ -3866,7 +3937,7 @@ function render_custom_fields( $content, $params = array() ) } else { // Display an error for not public custom field: - $content = str_replace( $source_tag, ''.sprintf( T_('The field "%s" is not public.'), $field_name ).'', $content ); + $content = str_replace( $source_tag, get_rendering_error( sprintf( T_('The field "%s" is not public.'), $field_name ), 'span' ), $content ); } } } @@ -3893,6 +3964,31 @@ function render_custom_fields( $content, $params = array() ) */ function render_other_item_data( $content, $params = array() ) { + $params = array_merge( array( + 'render_tag_item_field' => true, + 'render_tag_item_titlelink' => true, + 'render_tag_item_url' => true, + ), $params ); + + $render_tags = array(); + if( $params['render_tag_item_field'] ) + { // Render short tag [item:123:field:] + $render_tags[] = 'field'; + } + if( $params['render_tag_item_titlelink'] ) + { // Render short tag [item:123:titlelink] + $render_tags[] = 'titlelink'; + } + if( $params['render_tag_item_url'] ) + { // Render short tag [item:123:url] + $render_tags[] = 'url'; + } + + if( empty( $render_tags ) ) + { // No tags for rendering: + return $content; + } + if( isset( $params['check_code_block'] ) && $params['check_code_block'] && ( ( stristr( $content, 'render_other_item_data() on everything outside code/pre: $params['check_code_block'] = false; @@ -3903,7 +3999,7 @@ function render_other_item_data( $content, $params = array() ) } // Find all matches with tags of parent data: - preg_match_all( '/\[(parent|item:[^:]+):([a-z]+):?([^\]]*)?\]/i', $content, $tags ); + preg_match_all( '/\[(parent|item:[^:]+):('.implode( '|', $render_tags ).'):?([^\]]*)?\]/i', $content, $tags ); if( count( $tags[0] ) > 0 ) { // If at least one other item tag is found in content: @@ -3913,7 +4009,7 @@ function render_other_item_data( $content, $params = array() ) { // Get data of item parent: if( ! ( $other_Item = & $this->get_parent_Item() ) ) { // Display error message if parent doesn't exist: - $content = str_replace( $tags[0][ $t ], ''.T_('This Item has no parent.').'', $content ); + $content = str_replace( $tags[0][ $t ], get_rendering_error( T_('This Item has no parent.'), 'span' ), $content ); continue; } } @@ -3925,7 +4021,7 @@ function render_other_item_data( $content, $params = array() ) if( ! ( $other_item_data_is_number && $other_Item = & $ItemCache->get_by_ID( $other_item_ID_slug, false, false ) ) && ! ( ! $other_item_data_is_number && $other_Item = & $ItemCache->get_by_urltitle( $other_item_ID_slug, false, false ) ) ) { // Display error message if other item is not found by ID and slug: - $content = str_replace( $tags[0][ $t ], ''.sprintf( T_('The Item %s doesn\'t exist.'), ''.$other_item_ID_slug.'' ).'', $content ); + $content = str_replace( $tags[0][ $t ], get_rendering_error( sprintf( T_('The Item %s doesn\'t exist.'), ''.$other_item_ID_slug.'' ), 'span' ), $content ); continue; } } @@ -3938,7 +4034,7 @@ function render_other_item_data( $content, $params = array() ) $field_value = $other_Item->get_custom_field_formatted( $field_name, $params ); if( $field_value === false ) { // Wrong field request, display error: - $content = str_replace( $source_tag, ''.sprintf( T_('The field "%s" does not exist.'), $field_name ).'', $content ); + $content = str_replace( $source_tag, get_rendering_error( sprintf( T_('The field "%s" does not exist.'), $field_name ), 'span' ), $content ); } else { // Display field value: @@ -3949,7 +4045,7 @@ function render_other_item_data( $content, $params = array() ) } else { // Display an error for not public custom field: - $content = str_replace( $source_tag, ''.sprintf( T_('The field "%s" is not public.'), $field_name ).'', $content ); + $content = str_replace( $source_tag, get_rendering_error( sprintf( T_('The field "%s" is not public.'), $field_name ), 'span' ), $content ); } } break; @@ -3982,6 +4078,26 @@ function render_other_item_data( $content, $params = array() ) */ function render_collection_data( $content, $params = array() ) { + $params = array_merge( array( + 'render_tag_coll_name' => true, + 'render_tag_coll_shortname' => true, + ), $params ); + + $render_tags = array(); + if( $params['render_tag_coll_name'] ) + { // Render short tag [coll:name] + $render_tags[] = 'name'; + } + if( $params['render_tag_coll_shortname'] ) + { // Render short tag [coll:shortname] + $render_tags[] = 'shortname'; + } + + if( empty( $render_tags ) ) + { // No tags for rendering: + return $content; + } + if( isset( $params['check_code_block'] ) && $params['check_code_block'] && ( ( stristr( $content, 'render_collection_data() on everything outside code/pre: $params['check_code_block'] = false; @@ -3992,7 +4108,7 @@ function render_collection_data( $content, $params = array() ) } // Find all matches with tags of collection data: - preg_match_all( '/\[coll:([a-z]+)\]/i', $content, $tags ); + preg_match_all( '/\[coll:('.implode( '|', $render_tags ).')\]/i', $content, $tags ); if( count( $tags[0] ) > 0 ) { // If at least one collection tag is found in content: @@ -4032,6 +4148,15 @@ function render_collection_data( $content, $params = array() ) */ function render_link_data( $content, $params = array() ) { + $params = array_merge( array( + 'render_tag_item_link' => true, + ), $params ); + + if( ! $params['render_tag_item_link'] ) + { // No tags for rendering: + return $content; + } + if( isset( $params['check_code_block'] ) && $params['check_code_block'] && ( ( stristr( $content, 'render_link_data() on everything outside code/pre: $params['check_code_block'] = false; @@ -4052,7 +4177,7 @@ function render_link_data( $content, $params = array() ) { // Try to use parent: if( ! ( $other_Item = & $this->get_parent_Item() ) ) { // Display error message if parent doesn't exist: - $content = substr_replace( $content, ''.T_('This Item has no parent.').'', strpos( $content, $source_tag ), strlen( $source_tag ) ); + $content = substr_replace( $content, get_rendering_error( T_('This Item has no parent.'), 'span' ), strpos( $content, $source_tag ), strlen( $source_tag ) ); continue; } } @@ -4064,7 +4189,7 @@ function render_link_data( $content, $params = array() ) if( ! ( $other_item_data_is_number && $other_Item = & $ItemCache->get_by_ID( $other_item_ID_slug, false, false ) ) && ! ( ! $other_item_data_is_number && $other_Item = & $ItemCache->get_by_urltitle( $other_item_ID_slug, false, false ) ) ) { // Display error message if other item is not found by ID and slug: - $content = str_replace( $tags[0][ $t ], ''.sprintf( T_('The Item %s doesn\'t exist.'), ''.$other_item_ID_slug.'' ).'', $content ); + $content = str_replace( $tags[0][ $t ], get_rendering_error( sprintf( T_('The Item %s doesn\'t exist.'), ''.$other_item_ID_slug.'' ), 'span' ), $content ); continue; } } @@ -4082,19 +4207,24 @@ function render_link_data( $content, $params = array() ) $field_value = $other_Item->get_custom_field_value( $url_field_code, 'url' ); if( $field_value === false ) { // Wrong field request, display error: - $link_html = ''.sprintf( T_('The field "%s" does not exist.'), $url_field_code ).''; + $link_html = get_rendering_error( sprintf( T_('The field "%s" does not exist.'), $url_field_code ), 'span' ); } elseif( ! $custom_fields[ $url_field_code ]['public'] ) { // Display an error for not public custom field: - $link_html = ''.sprintf( T_('The field "%s" is not public.'), $url_field_code ).''; + $link_html = get_rendering_error( sprintf( T_('The field "%s" is not public.'), $url_field_code ), 'span' ); } elseif( $field_value === '' ) { // Empty field value, display error: - $link_html = ''.sprintf( T_('Referenced URL field is empty.'), $url_field_code ).''; + $link_html = get_rendering_error( sprintf( T_('Referenced URL field is empty.'), $url_field_code ), 'span' ); } else { // Display URL field as html link: - $link_class = empty( $link_data[1] ) ? '' : ' class="'.trim( str_replace( '.', ' ', $link_data[1] ) ).'"'; + $link_class = empty( $link_data[1] ) ? '' : str_replace( '.', ' ', $link_data[1] ); + if( empty( $tags[4][ $t ] ) ) + { // Add style class to break long urls: + $link_class .= ' linebreak'; + } + $link_class = ' class="'.trim( $link_class ).'"'; $link_text = empty( $tags[4][ $t ] ) ? $field_value : $tags[4][ $t ]; $link_html = ''.$link_text.''; } @@ -4117,6 +4247,26 @@ function render_content_blocks( $content, $params = array() ) { global $content_block_items; + $params = array_merge( array( + 'render_tag_include' => true, + 'render_tag_cblock' => true, + ), $params ); + + $render_tags = array(); + if( $params['render_tag_include'] ) + { // Render short tag [include:] + $render_tags[] = 'include'; + } + if( $params['render_tag_cblock'] ) + { // Render short tag [cblock:] + $render_tags[] = 'cblock'; + } + + if( empty( $render_tags ) ) + { // No tags for rendering: + return $content; + } + if( isset( $params['check_code_block'] ) && $params['check_code_block'] && ( ( stristr( $content, 'render_content_blocks() on everything outside code/pre: $params['check_code_block'] = false; @@ -4127,7 +4277,7 @@ function render_content_blocks( $content, $params = array() ) } // Find all matches with tags of content block posts: - preg_match_all( '/\[(include|cblock):?([^\]]*)?\]/i', $content, $tags ); + preg_match_all( '/\[('.implode( '|', $render_tags ).'):?([^\]]*)?\]/i', $content, $tags ); $ItemCache = & get_ItemCache(); @@ -4160,7 +4310,7 @@ function render_content_blocks( $content, $params = array() ) $wrong_item_info = ''.$item_ID_slug.''; } // Replace inline content block tag with error message about wrong referenced item: - $content = str_replace( $source_tag, '

    '.sprintf( T_('The referenced Item (%s) is not a Content Block.'), utf8_trim( $wrong_item_info ) ).'

    ', $content ); + $content = str_replace( $source_tag, get_rendering_error( sprintf( T_('The referenced Item (%s) is not a Content Block.'), utf8_trim( $wrong_item_info ) ) ), $content ); continue; } elseif( get_status_permvalue( $this->get( 'status' ) ) > get_status_permvalue( $content_Item->get( 'status' ) ) ) @@ -4177,7 +4327,7 @@ function render_content_blocks( $content, $params = array() ) // - Review // For example, if content block Item has a status "Public" but current/parent Item has a status "Community", // then such content block Item cannot be included into the current/parent Item. - $content = str_replace( $source_tag, '

    '.sprintf( T_('The visibility level of the content block "%s" is not sufficient.'), '#'.$content_Item->ID.' '.$content_Item->get( 'urltitle' ) ).'

    ', $content ); + $content = str_replace( $source_tag, get_rendering_error( sprintf( T_('The visibility level of the content block "%s" is not sufficient.'), '#'.$content_Item->ID.' '.$content_Item->get( 'urltitle' ) ) ), $content ); continue; } elseif( $content_Item->get( 'creator_user_ID' ) != $this->get( 'creator_user_ID' ) && @@ -4186,11 +4336,22 @@ function render_content_blocks( $content, $params = array() ) ( ! ( $info_Blog = & get_setting_Blog( 'info_blog_ID' ) ) || $content_Item->get_blog_ID() != $info_Blog->ID ) ) { // We can display a content block item with at least one condition: - // - Content block Item has same owner as owner of parent Item, - // - Content block Item has same owner as owner of parent Item's collection, - // - Content block Item is in same collection as parent Item, - // - Content block Item from collection for shared content blocks: - $content = str_replace( $source_tag, '

    '.sprintf( T_('Content block "%s" cannot be included here. It must be in the same collection or the info pages collection; in any other case, it must have the same owner.'), '#'.$content_Item->ID.' '.$content_Item->get( 'urltitle' ) ).'

    ', $content ); + // 1. Content block Item has same owner as owner of parent Item, + // 2. Content block Item has same owner as owner of parent Item's collection, + // 3. Content block Item is in same collection as parent Item, + // 4. Content block Item from collection for shared content blocks: + $content_Blog = & $content_Item->get_Blog(); + $content = str_replace( $source_tag, get_rendering_error( sprintf( + T_('Content block #%d %s (Coll #%d) (Owner: %s) cannot be included here. It must be in the same collection as including Item (Coll #%d) or the info pages collection (Coll #%d)').'; '. + T_('in any other case, it must have the same owner as the including Item (Item #%d) (Owner: %s) or the same owner as the including Item\'s collection (Owner: %s).'), + $content_Item->ID, ''.$content_Item->get( 'urltitle' ).'', // Content block #%d %s + $content_Item->get_blog_ID(), // (Coll #%d) + get_user_identity_link( NULL, $content_Item->get( 'creator_user_ID' ) ), // (Owner: %s) + $this->get_blog_ID(), // as including Item (Coll #%d) + ( $info_Blog = & get_setting_Blog( 'info_blog_ID' ) ) ? $info_Blog->ID : 0, // the info pages collection (Coll #%d) + $this->ID, get_user_identity_link( NULL, $this->get( 'creator_user_ID' ) ), // the including Item (Item #%d) (Owner: %s) + $item_Blog ? get_user_identity_link( NULL, $item_Blog->get( 'owner_user_ID' ) ) : ''.T_('No collection found').'' // the including Item\'s collection (Owner: %s) + ) ), $content ); continue; } @@ -4201,7 +4362,7 @@ function render_content_blocks( $content, $params = array() ) if( in_array( $content_Item->ID, $content_block_items ) ) { // Replace inline content block tag with error message about recursion: - $content = str_replace( $source_tag, '

    '.sprintf( T_('Content inclusion loop detected. Not including "%s".'), '#'.$content_Item->ID.' '.$content_Item->get( 'title' ) ).'

    ', $content ); + $content = str_replace( $source_tag, get_rendering_error( sprintf( T_('Content inclusion loop detected. Not including "%s".'), '#'.$content_Item->ID.' '.$content_Item->get( 'title' ) ) ), $content ); continue; } @@ -4241,10 +4402,26 @@ function render_content_blocks( $content, $params = array() ) if( get_param( 'preview' ) === 1 && get_param( 'preview_block' ) === 1 ) { // Display orange debug wrapper around included content-block Item: + // Item debug info with Title + Slug: + $title_debug_info = ''.$content_Item->get( 'title' ).' ('.$content_Item->get( 'urltitle' ).')'; + if( $item_edit_url = $content_Item->get_edit_url() ) + { // Link to edit Item if current User has a permission: + $title_debug_info = ''.$title_debug_info.''; + } + // Content Template debug info with Name + Code: + $TemplateCache = & get_TemplateCache(); + if( $content_Template = & $TemplateCache->get_localized_by_code( $tag_template, false, false ) ) + { // Display template info: + $template_debug_info = ''.$content_Template->get( 'name' ).' ('.$content_Template->get( 'code' ).')'; + if( check_user_perm( 'options', 'edit' ) ) + { // Link to edit Template if current User has a permission: + $template_debug_info = ''.$template_debug_info.''; + } + $title_debug_info .= ' / '.$template_debug_info; + } $current_tag_item_content = '
    '."\n" .'
    ' - .$content_Item->get_edit_link( array( 'before' => '', 'after' => '', 'text' => T_('Edit') ) ) - .''.$content_Item->get( 'title' ).' ('.$content_Item->get( 'urltitle' ).')' + .$title_debug_info .'
    '."\n" .$current_tag_item_content."\n" .'
    '; @@ -4326,8 +4503,14 @@ function render_templates( $content, $params = array() ) { $params = array_merge( array( 'check_code_block' => true, + 'render_tag_template' => true, ), $params ); + if( ! $params['render_tag_template'] ) + { // No tags for rendering: + return $content; + } + if( $params['check_code_block'] && ( ( stristr( $content, 'get_by_code( $params[0], false, false ) ) ) { // Template is not found: - return 'Template "'.$params[0].'" is not found for '.$m[0].''; + return get_rendering_error( 'Template "'.$params[0].'" is not found for '.$m[0].'', 'span' ); } if( isset( $params[1] ) ) @@ -4386,8 +4569,14 @@ function render_switchable_blocks( $content, $params = array() ) { $params = array_merge( array( 'check_code_block' => true, + 'render_tag_switchable_div' => true, ), $params ); + if( ! $params['render_tag_switchable_div'] ) + { // No tags for rendering: + return $content; + } + if( $params['check_code_block'] && ( ( stristr( $content, 'ID.']'; // Make one "gallery" per post. } + if( empty( $params['image_alt'] ) ) + { // Override image alt text by current Item title only when it is not passed e.g. from inline/short tag `[image:123::Custom Alt Text]`: + $params['image_alt'] = $this->get( 'title' ); + } + // Generate the IMG tag with all the alt, title and desc if available return $Link->get_tag( array_merge( $params, array( 'image_link_to' => $link_to, // can be URL, can be empty 'image_link_title' => $link_title, 'image_link_rel' => $link_rel, - 'image_alt' => $this->get( 'title' ), ) ) ); } @@ -5198,9 +5392,9 @@ function get_images( $params = array(), $format = 'htmlbody' ) 'gallery_order' => '', // 'ASC', 'DESC', 'RAND' 'gallery_link_rel' => 'lightbox[p'.$this->ID.']', 'restrict_to_image_position' => 'teaser,teaserperm,teaserlink,aftermore', - // 'teaser'|'teaserperm'|'teaserlink'|'aftermore'|'inline'|'cover', + // 'teaser'|'teaserperm'|'teaserlink'|'aftermore'|'inline'|'cover'|'background', // '#teaser_all' => 'teaser,teaserperm,teaserlink', - // '#cover_and_teaser_all' => 'cover,teaser,teaserperm,teaserlink' + // '#cover_and_teaser_all' => 'cover,background,teaser,teaserperm,teaserlink' 'limit' => 1000, // Max # of images displayed 'placeholder' => '', // HTML to be displayed if no image; possible codes: #folder_icon 'data' => & $r, @@ -5227,7 +5421,7 @@ function get_images( $params = array(), $format = 'htmlbody' ) $params['restrict_to_image_position'] = 'teaser,teaserperm,teaserlink'; break; case '#cover_and_teaser_all': - $params['restrict_to_image_position'] = 'cover,teaser,teaserperm,teaserlink'; + $params['restrict_to_image_position'] = 'cover,background,teaser,teaserperm,teaserlink'; break; } @@ -5252,6 +5446,9 @@ function get_images( $params = array(), $format = 'htmlbody' ) case '#file_text_icon'; $placeholder_html = '
    '; break; + case '#file_thumbnail_text_icon'; + $placeholder_html = '
    '; + break; } return str_replace( '$url$', $this->get_item_url( $params['target_blog'], $params['post_navigation'], $params['nav_target'] ), $placeholder_html ); } @@ -5396,7 +5593,7 @@ function & get_image_File( $params = array() ) $params['position'] = 'teaser,teaserperm,teaserlink'; break; case '#cover_and_teaser_all': - $params['position'] = 'cover,teaser,teaserperm,teaserlink'; + $params['position'] = 'cover,background,teaser,teaserperm,teaserlink'; break; } @@ -5463,7 +5660,7 @@ function get_image_url( $params = array() ) * Get URL of a first cover image * * @param string Restrict to files/images linked to a specific position. - * Position can be 'cover'|'teaser'|'aftermore'|'inline' + * Position can be 'cover'|'background'|'teaser'|'aftermore'|'inline' * Use comma as separator * @return string|NULL cover URL or NULL if it doesn't exist */ @@ -5500,7 +5697,7 @@ function get_background_image_css( $params = array() ) * Get a number of images linked to the current Item * * @param string Restrict to files/images linked to a specific position. - * Position can be 'teaser'|'teaserperm'|'teaserlink'|'aftermore'|'inline'|'cover' + * Position can be 'teaser'|'teaserperm'|'teaserlink'|'aftermore'|'inline'|'cover'|'background' * Use comma as separator * @param integer Number of images */ @@ -5550,8 +5747,8 @@ function get_files( $params = array(), $format = 'htmlbody' ) // sam2kb> It's needed only for flexibility, in the meantime if user attaches 200 files he expects to see all of them in skin, I think. 'limit_attach' => 1000, // Max # of files displayed 'limit' => 1000, - // Optionally restrict to files/images linked to specific position: 'teaser'|'teaserperm'|'teaserlink'|'aftermore'|'inline'|'cover' - 'restrict_to_image_position' => 'cover,teaser,teaserperm,teaserlink,aftermore,attachment', + // Optionally restrict to files/images linked to specific position: 'teaser'|'teaserperm'|'teaserlink'|'aftermore'|'inline'|'cover'|'background' + 'restrict_to_image_position' => 'cover,background,teaser,teaserperm,teaserlink,aftermore,attachment', 'data' => '', 'attach_format' => '$icon_link$ $file_link$ $file_size$ $file_desc$', // $icon_link$ $icon$ $file_link$ $file_size$ $file_desc$ 'file_link_format' => '$file_name$', // $icon$ $file_name$ $file_size$ $file_desc$ @@ -5631,7 +5828,7 @@ function get_files( $params = array(), $format = 'htmlbody' ) continue; } - if( $File->is_image() ) + if( ! isset( $params['image_attachment'] ) && $File->is_image() ) { // Skip images (except those in the attachment position) because these are displayed inline already // fp> TODO: have a setting for each linked file to decide whether it should be displayed inline or as an attachment continue; @@ -5680,8 +5877,9 @@ function get_files( $params = array(), $format = 'htmlbody' ) } if( $File->exists() ) { // Get file link to download if file exists: + $file_download_url = $this->get_coll_setting( 'download_enable' ) ? $Link->get_download_url() : NULL; $file_link = ( strpos( $params['attach_format'], '$file_link$' ) !== false ) ? - $File->get_view_link( $file_link_text, NULL, NULL, $file_link_format, $params['file_link_class'], $Link->get_download_url() ) : ''; + $File->get_view_link( $file_link_text, NULL, NULL, $file_link_format, $params['file_link_class'], $file_download_url ) : ''; } else { // File doesn't exist, We cannot display a link, Display only file name and warning: @@ -5950,8 +6148,8 @@ function get_feedback_link( $params = array() ) 'stay_in_same_collection' => 'auto', // 'auto' - follow 'allow_crosspost_urls' if we are cross posted, true - always stay in same collection if we are cross posted, false - always go to permalink if we are cross posted ), $params ); - if( $params['show_in_single_mode'] == false && is_single_page() ) - { // We are viewing the single page for this pos, which (typically) )contains comments, so we don't want to display this link + if( $params['show_in_single_mode'] == false && is_single_page( $this->ID ) ) + { // We are viewing the single page for this Item, which (typically) contains comments, so we don't want to display this link return; } @@ -6367,7 +6565,7 @@ function feedback_moderation( $type = 'feedbacks', $before = '', $after = '', ), $params ); */ - if( isset($current_User) && $current_User->check_perm( 'blog_comment!draft', 'moderate', false, $this->get_blog_ID() ) ) + if( isset($current_User) && check_user_perm( 'blog_comment!draft', 'moderate', false, $this->get_blog_ID() ) ) { // We have permission to edit comments: if( $edit_comments_link == '#' ) { // Use default link: @@ -6462,12 +6660,10 @@ function footer( $params ) */ function get_delete_link( $before = ' ', $after = ' ', $text = '#', $title = '#', $class = '', $button = false, $actionurl = '#', $confirm_text = '#', $redirect_to = '' ) { - global $current_User, $admin_url; - - if( ! is_logged_in( false ) ) return false; + global $admin_url; - if( ! $current_User->check_perm( 'item_post!CURSTATUS', 'delete', false, $this ) ) - { // User has right to delete this post + if( ! check_user_perm( 'item_post!CURSTATUS', 'delete', false, $this, false ) ) + { // User has no rights to delete this Item: return false; } @@ -6556,7 +6752,7 @@ function delete_link( $before = ' ', $after = ' ', $text = '#', $title = '#', $c */ function get_copy_link( $params = array() ) { - global $current_User, $admin_url; + global $admin_url; $actionurl = $this->get_copy_url($params); if( ! $actionurl ) @@ -6610,7 +6806,7 @@ function get_copy_link( $params = array() ) */ function get_copy_url( $params = array() ) { - global $admin_url, $current_User; + global $admin_url; if( ! is_logged_in( false ) ) return false; @@ -6636,12 +6832,12 @@ function get_copy_url( $params = array() ) { // Current user can copy this post from Front-office $url = url_add_param( $this->Blog->get( 'url' ), 'disp=edit&cp='.$this->ID ); } - else if( $current_User->check_perm( 'admin', 'restricted' ) ) + else if( check_user_perm( 'admin', 'restricted' ) ) { // Current user can copy this post from Back-office $url = $admin_url.'?ctrl=items&action=copy&blog='.$this->Blog->ID.'&p='.$this->ID; } } - else if( $current_User->check_perm( 'admin', 'restricted' ) ) + else if( check_user_perm( 'admin', 'restricted' ) ) { // Copy a post from Back-office $url = $admin_url.'?ctrl=items&action=copy&blog='.$this->Blog->ID.'&p='.$this->ID; if( $params['save_context'] ) @@ -6899,24 +7095,17 @@ function get_unlink_version_link( $params = array() ) */ function can_link_version( $allow_new_item = false ) { - global $current_User; - if( ! $allow_new_item && ! $this->ID ) { // Item must be saved in DB: return false; } - if( ! is_logged_in( false ) ) - { // User must be logged in - return false; - } - - if( ! $current_User->check_perm( 'item_post!CURSTATUS', 'edit', false, $this ) ) + if( ! check_user_perm( 'item_post!CURSTATUS', 'edit', false, $this, false ) ) { // User has no rights to edit this Item return false; } - if( ! is_admin_page() || ! $current_User->check_perm( 'admin', 'restricted' ) ) + if( ! is_admin_page() || ! check_user_perm( 'admin', 'restricted' ) ) { // This feature is allowed only for back-office yet return false; } @@ -6938,7 +7127,7 @@ function can_link_version( $allow_new_item = false ) */ function get_edit_link( $params = array() ) { - global $current_User, $admin_url; + global $admin_url; $actionurl = $this->get_edit_url($params); if( ! $actionurl ) @@ -6979,14 +7168,10 @@ function get_edit_link( $params = array() ) */ function can_be_edited() { - global $current_User; - // Item must be stored in DB: return ! empty( $this->ID ) && - // User must be logged in and activated: - is_logged_in( false ) && - // User must has a permission to edit this Item: - $current_User->check_perm( 'item_post!CURSTATUS', 'edit', false, $this ); + // User must be logged in and activated and has a permission to edit this Item: + check_user_perm( 'item_post!CURSTATUS', 'edit', false, $this, false ); } @@ -6998,12 +7183,7 @@ function can_be_edited() */ function get_edit_url( $params = array() ) { - global $admin_url, $current_User; - - if( ! $this->can_be_edited() ) - { // Don't allow to edit this Item if it cannot be edited by curren User: - return false; - } + global $admin_url; // default params $params += array( @@ -7011,20 +7191,26 @@ function get_edit_url( $params = array() ) 'glue' => '&', 'force_in_skin_editing' => false, 'force_backoffice_editing' => false, + 'check_perm' => true, // FALSE - if this link must be displayed even if current has no permission to view item history page ); + if( empty( $this->ID ) || ( $params['check_perm'] && ! $this->can_be_edited() ) ) + { // Don't allow to edit this Item if it is not created yet or if this Item cannot be edited by current User: + return false; + } + $this->load_Blog(); $url = false; if( $this->Blog->get_setting( 'in_skin_editing' ) && - ( ! $params['force_backoffice_editing'] || ! $current_User->check_perm( 'admin', 'restricted' ) ) && + ( ! $params['force_backoffice_editing'] || ! check_user_perm( 'admin', 'restricted' ) ) && ( ! is_admin_page() || $params['force_in_skin_editing'] ) ) { // We have a mode 'In-skin editing' for the current Blog - if( check_item_perm_edit( $this->ID, false ) ) + if( ! $params['check_perm'] || check_item_perm_edit( $this->ID, false ) ) { // Current user can edit this post $url = url_add_param( $this->Blog->get( 'url' ), 'disp=edit&p='.$this->ID ); } } - else if( $current_User->check_perm( 'admin', 'restricted' ) ) + else if( ! $params['check_perm'] || check_user_perm( 'admin', 'restricted' ) ) { // Edit a post from Back-office $url = $admin_url.'?ctrl=items'.$params['glue'].'action=edit'.$params['glue'].'p='.$this->ID.$params['glue'].'blog='.$this->Blog->ID; if( $params['save_context'] ) @@ -7107,19 +7293,14 @@ function get_propose_change_link( $params = array() ) */ function get_propose_change_url( $params = array() ) { - global $admin_url, $current_User; - - if( ! is_logged_in( false ) ) - { // User must be logged in and activated for this action: - return false; - } + global $admin_url; if( ! $this->ID ) { // Don't display this button in preview mode: return false; } - if( ! $current_User->check_perm( 'blog_item_propose', 'edit', false, $this->get_blog_ID() ) ) + if( ! check_user_perm( 'blog_item_propose', 'edit', false, $this->get_blog_ID(), false ) ) { // User has no right to propose a change for this Item: return false; } @@ -7133,7 +7314,7 @@ function get_propose_change_url( $params = array() ) { // We have a mode 'In-skin editing' for the current Blog $url = url_add_param( $this->Blog->get( 'url' ), 'disp=proposechange&p='.$this->ID ); } - else if( $current_User->check_perm( 'admin', 'restricted' ) ) + else if( check_user_perm( 'admin', 'restricted' ) ) { // Edit a post from Back-office: $url = $admin_url.'?ctrl=items&action=propose&p='.$this->ID.'&blog='.$this->Blog->ID; if( $params['save_context'] ) @@ -7197,9 +7378,9 @@ function get_changes_link( $params = array() ) */ function get_changes_url( $glue = '&' ) { - global $current_User, $admin_url; + global $admin_url; - if( ! is_logged_in() || ! $current_User->check_perm( 'item_post!CURSTATUS', 'edit', false, $this ) ) + if( ! check_user_perm( 'item_post!CURSTATUS', 'edit', false, $this ) ) { // Current user cannot see item changes: return false; } @@ -7235,19 +7416,12 @@ function changes_link( $params = array() ) */ function get_merge_click_js() { - global $current_User; - - if( ! is_logged_in( false ) ) - { // Current User must be logged in and activated: - return false; - } - if( ! $this->ID ) { // Item must be stored in DB: return false; } - if( ! $current_User->check_perm( 'item_post!CURSTATUS', 'edit', false, $this ) ) + if( ! check_user_perm( 'item_post!CURSTATUS', 'edit', false, $this, false ) ) { // User has no right to edit this Item: return false; } @@ -7332,8 +7506,6 @@ function merge_link( $params = array() ) */ function get_next_status( $publish ) { - global $current_User; - if( !is_logged_in( false ) ) { return false; @@ -7351,7 +7523,7 @@ function get_next_status( $publish ) while( !$has_perm && ( $publish ? ( $curr_index < 4 ) : ( $curr_index > 0 ) ) ) { $curr_index = $publish ? ( $curr_index + 1 ) : ( $curr_index - 1 ); - $has_perm = $current_User->check_perm( 'item_post!'.$status_order[$curr_index][0], 'moderate', false, $this ); + $has_perm = check_user_perm( 'item_post!'.$status_order[$curr_index][0], 'moderate', false, $this ); } if( $has_perm ) { @@ -7376,18 +7548,15 @@ function get_next_status( $publish ) */ function get_publish_link( $before = ' ', $after = ' ', $text = '#', $title = '#', $class = '', $glue = '&', $save_context = true ) { - global $current_User, $admin_url; + global $admin_url; if( $this->status != 'draft' ) { return false; } - if( ! is_logged_in( false ) ) return false; - - $this->load_Blog(); - if( ! ($current_User->check_perm( 'item_post!published', 'edit', false, $this )) - || ! ($current_User->check_perm( 'blog_edit_ts', 'edit', false, $this->Blog->ID ) ) ) + if( ! check_user_perm( 'item_post!published', 'edit', false, $this, false ) || + ! check_user_perm( 'blog_edit_ts', 'edit', false, $this->get_blog_ID(), false ) ) { // User has no right to publish this post now: return false; } @@ -7418,7 +7587,7 @@ function get_publish_link( $before = ' ', $after = ' ', $text = '#', $title = '# */ function highest_publish_link( $params = array() ) { - global $current_User, $admin_url; + global $admin_url; if( !is_logged_in( false ) ) { @@ -7448,7 +7617,7 @@ function highest_publish_link( $params = array() ) return false; } - if( ! ($current_User->check_perm( 'item_post!'.$highest_status, 'edit', false, $this ) ) ) + if( ! (check_user_perm( 'item_post!'.$highest_status, 'edit', false, $this ) ) ) { // User has no right to edit this post return false; } @@ -7623,12 +7792,10 @@ function next_status_link( $params, $publish ) */ function get_deprecate_link( $before = ' ', $after = ' ', $text = '#', $title = '#', $class = '', $glue = '&', $redirect_to = '' ) { - global $current_User, $admin_url; - - if( ! is_logged_in( false ) ) return false; + global $admin_url; - if( ($this->status == 'deprecated') // Already deprecated! - || ! ($current_User->check_perm( 'item_post!deprecated', 'edit', false, $this )) ) + if( $this->status == 'deprecated' || // Already deprecated! + ! check_user_perm( 'item_post!deprecated', 'edit', false, $this, false ) ) { // User has no right to deprecated this post: return false; } @@ -8375,7 +8542,7 @@ function set_creator_location( $location ) { global $current_User; - if( !isset( $current_User ) ) + if( ! is_logged_in() ) { // No logged in user return; } @@ -8458,6 +8625,7 @@ function insert( if( $post_comment_status == 'closed' || $post_comment_status == 'disabled' ) { // Check if item type allows these options: + $ItemTypeCache = & get_ItemTypeCache(); $ItemType = & $ItemTypeCache->get_by_ID( $item_typ_ID ); if( $post_comment_status == 'closed' && ! $ItemType->get( 'allow_closing_comments' ) ) { @@ -8474,6 +8642,14 @@ function insert( $item_typ_ID = 1; } + // Set Item Type here in order to get item type settings below: + $this->set( 'ityp_ID', $item_typ_ID ); + + if( ! $this->get_type_setting( 'allow_html' ) ) + { // Strip HTML tags from content if HTML is not allowed for Item Type of this Item: + $post_content = utf8_strip_tags( $post_content ); + } + if( $post_locale == '#' ) $post_locale = $default_locale; // echo 'INSERTING NEW POST '; @@ -8509,7 +8685,6 @@ function insert( $this->set( 'url', $post_url ); $this->set( 'comment_status', $post_comment_status ); $this->set_renderers( $post_renderers ); - $this->set( 'ityp_ID', $item_typ_ID ); $this->set( 'pst_ID', $item_st_ID ); $this->set( 'order', $postcat_order ); @@ -9094,7 +9269,7 @@ function dbupdate( $auto_track_modification = true, $update_slug = true, $update if( $this->get_type_setting( 'usage' ) == 'content-block' && empty( $this->content_block_invalidate_reported ) ) { // Display warning on updating of content block item: - global $admin_url, $current_User; + global $admin_url; // Get items where currently updated content block is included: $invalidated_items = $this->get_included_item_IDs( $this->ID.'|'.$this->get_slugs( '|' ) ); @@ -9109,9 +9284,8 @@ function dbupdate( $auto_track_modification = true, $update_slug = true, $update // Display info message about invalidated cache: $invalidate_message = TB_('INFO: you edited a content block.').' ' .sprintf( TB_('We invalidated %d pre-rendered Items that include the content block.'), $invalidated_items_num ).' '; - if( is_logged_in() && - $current_User->check_perm( 'admin', 'normal' ) && - $current_User->check_perm( 'options', 'view' ) ) + if( check_user_perm( 'admin', 'normal' ) && + check_user_perm( 'options', 'view' ) ) { // If current user has a permission to the clear tool: $Messages->add( $invalidate_message.sprintf( TB_('You may invalidate the complete pre-rendering cache NOW.'), 'href="'.$admin_url.'?ctrl=tools&action=del_itemprecache&'.url_crumb( 'tools' ).'" target="_blank"' ), 'note' ); } @@ -9384,17 +9558,31 @@ function get_autogenerated_excerpt( $maxlen = 254, $tail = '…' ) // Render inline tags to HTML code, except of inline file tags because they are removed below: $first_content_part = $this->render_inline_tags( $first_content_part, array( - 'render_inline_files' => false, - 'render_links' => false, - 'render_other_item' => false, - 'render_inline_widgets' => false, - 'render_block_widgets' => false, - 'render_switchable_blocks' => false, + 'render_tag_image' => false, + 'render_tag_file' => false, + 'render_tag_inline' => false, + 'render_tag_video' => false, + 'render_tag_audio' => false, + 'render_tag_thumbnail' => false, + 'render_tag_folder' => false, + 'render_tag_item_link' => false, + 'render_tag_item_field' => false, + 'render_tag_item_titlelink' => false, + 'render_tag_item_url' => false, + 'render_tag_item_subscribe' => false, + 'render_tag_item_emailcapture' => false, + 'render_tag_item_compare' => false, + 'render_tag_item_fields' => false, + 'render_tag_switcher' => false, + 'render_tag_switchable_div' => false, ) ); // Remove shorttags from excerpt // [image:123:caption:.class] [file:123:caption:.class] [inline:123:.class] etc: $first_content_part = preg_replace( '/\[[a-z]+:[^\]`]*\]/i', '', $first_content_part ); + // Clean up rendering errors from autogenerated excerpt: + $first_content_part = clear_rendering_errors( $first_content_part ); + return excerpt( $first_content_part, $maxlen, $tail ); } @@ -9980,7 +10168,7 @@ function send_proposed_change_notification( $iver_ID ) */ function send_assignment_notification( $executed_by_userid = NULL ) { - global $current_User, $Messages, $UserSettings; + global $Messages, $UserSettings; $notified_user_IDs = array(); @@ -10705,14 +10893,15 @@ function get( $parname ) */ function load_orders() { - if( ! isset( $this->orders ) && $this->ID > 0 ) + if( ! isset( $this->orders ) && ( $this->ID > 0 || isset( $this->parent_item_ID ) ) ) { // Initialize item orders in all assigned categories: + $item_ID = ( $this->ID > 0 ) ? $this->ID : $this->parent_item_ID; global $DB; - $SQL = new SQL( 'Get all orders per categories of Item #'.$this->ID ); + $SQL = new SQL( 'Get all orders per categories of Item #'.$item_ID ); $SQL->SELECT( 'cat_ID, cat_blog_ID, postcat_order' ); $SQL->FROM( 'T_postcats' ); $SQL->FROM_add( 'INNER JOIN T_categories ON cat_ID = postcat_cat_ID' ); - $SQL->WHERE( 'postcat_post_ID = '.$this->ID ); + $SQL->WHERE( 'postcat_post_ID = '.$item_ID ); $orders = $DB->get_results( $SQL ); $this->orders = array(); $this->orders_per_coll = array(); @@ -12220,7 +12409,7 @@ function get_read_status() return 'read'; } - global $DB, $current_User; + global $DB; $read_date = $this->get_user_data( 'item_date' ); @@ -12456,10 +12645,10 @@ function check_goal() */ function get_type_edit_link( $attr = 'link', $link_text = '', $link_title = '' ) { - global $admin_url, $current_User; + global $admin_url; // Check if current user can edit the type of this item - $has_perm_edit = is_logged_in() && $current_User->check_perm( 'item_post!CURSTATUS', 'edit', false, $this ); + $has_perm_edit = check_user_perm( 'item_post!CURSTATUS', 'edit', false, $this ); if( $has_perm_edit ) { // Initialize url params only when current user has a permission to edit this @@ -12885,8 +13074,6 @@ function flag( $params = array() ) */ function get_flag( $params = array() ) { - global $current_User; - $params = array_merge( array( 'before' => '', 'after' => '', @@ -13423,14 +13610,7 @@ function can_refresh_contents_last_updated() return false; } - if( ! is_logged_in( false ) ) - { // If current user is not logged in or not activated: - return false; - } - - global $current_User; - - if( ! $current_User->check_perm( 'item_post!CURSTATUS', 'edit', false, $this ) ) + if( ! check_user_perm( 'item_post!CURSTATUS', 'edit', false, $this, false ) ) { // If user has no perm to edit this Item: return false; } @@ -13599,7 +13779,7 @@ function get_social_media_image( $use_category_fallback = false, $use_site_fallb } $LinkOwner = new LinkItem( $this ); - if( $LinkList = $LinkOwner->get_attachment_LinkList( 1000, 'cover,teaser,teaserperm,teaserlink,inline', 'image', array( + if( $LinkList = $LinkOwner->get_attachment_LinkList( 1000, 'cover,background,teaser,teaserperm,teaserlink,inline', 'image', array( 'sql_select_add' => ', CASE WHEN link_position = "cover" THEN 1 WHEN link_position IN ( "teaser", "teaserperm", "teaserlink" ) THEN 2 ELSE 3 END AS link_priority', 'sql_order_by' => 'link_priority ASC, link_order ASC' ) ) ) { // Item has linked files @@ -13869,7 +14049,7 @@ function can_propose_change( $redirect = false ) return false; } - if( ! $current_User->check_perm( 'blog_item_propose', 'edit', false, $this->get_blog_ID() ) ) + if( ! check_user_perm( 'blog_item_propose', 'edit', false, $this->get_blog_ID() ) ) { // User has no right to propose a change for this Item: // Display a message: @@ -14187,16 +14367,15 @@ function update_attachments_folder() */ function display_notification_message( $message, $log_messages = false, $message_type = 'note', $message_group = NULL ) { - global $current_User, $Messages; + global $Messages; if( $log_messages == 'cron_job' ) { // Log message for cron job: cron_log_append( $message."\n", $message_type ); } elseif( ! empty( $this->ID ) && // Item must be stored in DB - is_logged_in( false ) && // User must be logged in and activated - // User must be a collection admin - $current_User->check_perm( 'blog_admin', 'edit', false, $this->get_blog_ID() ) ) + // User must be logged in and activated and be a collection admin + check_user_perm( 'blog_admin', 'edit', false, $this->get_blog_ID(), false ) ) { // Display notification message only for collection admin: if( $message_group === NULL ) { // Set default group title: @@ -14411,17 +14590,13 @@ function & get_version_Item( $locale, $check_visibility = true ) */ function can_edit_workflow( $permname = 'any', $assert = false ) { - global $current_User; - $perm = // Main Category must be defined for this Item in order to check permission in Collection of the Category: ! empty( $this->main_cat_ID ) && - // User must be logged in: - is_logged_in() && // Workflow must be enabled for current Collection: $this->get_coll_setting( 'use_workflow' ) && // Current User must has a permission to be assigned for tasks of the current Collection: - $current_User->check_perm( 'blog_can_be_assignee', 'edit', $assert, $this->get_blog_ID() ); + check_user_perm( 'blog_can_be_assignee', 'edit', $assert, $this->get_blog_ID() ); if( $perm ) { // Additional checking for several permissions when main checking is true: @@ -14429,9 +14604,9 @@ function can_edit_workflow( $permname = 'any', $assert = false ) { case 'any': // Check if current User can edit at least one workflow property: - $perm = $current_User->check_perm( 'blog_workflow_status', 'edit', false, $this->get_blog_ID() ) || - $current_User->check_perm( 'blog_workflow_user', 'edit', false, $this->get_blog_ID() ) || - $current_User->check_perm( 'blog_workflow_priority', 'edit', false, $this->get_blog_ID() ); + $perm = check_user_perm( 'blog_workflow_status', 'edit', false, $this->get_blog_ID() ) || + check_user_perm( 'blog_workflow_user', 'edit', false, $this->get_blog_ID() ) || + check_user_perm( 'blog_workflow_priority', 'edit', false, $this->get_blog_ID() ); break; case 'deadline': // Deadline has additional collection setting to be enabled: @@ -14456,14 +14631,14 @@ function can_edit_workflow( $permname = 'any', $assert = false ) return $perm; case 'status': // Check if current User can edit the workflow status: - return $current_User->check_perm( 'blog_workflow_status', 'edit', $assert, $this->get_blog_ID() ); + return check_user_perm( 'blog_workflow_status', 'edit', $assert, $this->get_blog_ID() ); case 'user': // Check if current User can edit the workflow user: - return $current_User->check_perm( 'blog_workflow_user', 'edit', $assert, $this->get_blog_ID() ); + return check_user_perm( 'blog_workflow_user', 'edit', $assert, $this->get_blog_ID() ); case 'priority': case 'deadline': // Check if current User can edit the workflow priority or deadline: - return $current_User->check_perm( 'blog_workflow_priority', 'edit', $assert, $this->get_blog_ID() ); + return check_user_perm( 'blog_workflow_priority', 'edit', $assert, $this->get_blog_ID() ); default: // Wrong request: debug_die( 'Unhandled Item workflow permission name "'.$permname.'"' ); @@ -14575,6 +14750,7 @@ function get_front_edit_fields() 'short_title', 'instruction', 'attachments', + 'workflow', 'text', 'tags', 'excerpt', @@ -14655,7 +14831,33 @@ function tinyurl_redirect( $slug = NULL, $slug_extra_term = NULL ) $redirect_to = pro_tinyurl_redirect_add_params( $redirect_to, $item_Blog, $slug, $slug_extra_term ); } + // Keep ONLY allowed params from current URL in the canonical URL by configs AND Item's switchable params: + $redirect_to = url_keep_canonicals_params( $redirect_to, '&', array_keys( $this->get_switchable_params() ) ); + header_redirect( $redirect_to, 302 ); // 302 is easier for debugging; TODO: setting to choose type of redirect } + + + /** + * Get info for form field selector + * + * @return string + */ + function get_form_selector_info() + { + $r = ''; + + $status_icons = get_visibility_statuses( 'icons' ); + if( isset( $status_icons[ $this->get( 'status' ) ] ) ) + { // Status colored icon: + $r .= $status_icons[ $this->get( 'status' ) ]; + } + // Title with link to permament url: + $r .= ' '.$this->get_title( array( 'link_type' => 'permalink' ) ); + // Icon to edit if current User has a permission: + $r .= ' '.$this->get_edit_link( array( 'text' => '#icon#' ) ); + + return $r; + } } ?> diff --git a/inc/items/model/_item.funcs.php b/inc/items/model/_item.funcs.php index 0780e4f7b33..c527ea72a68 100644 --- a/inc/items/model/_item.funcs.php +++ b/inc/items/model/_item.funcs.php @@ -124,7 +124,7 @@ function init_MainList( $items_nb_limit ) } } - param( 'more', 'integer', 0, true ); + param( 'more', 'integer', 0, 'ifnotyet' ); param( 'page', 'integer', 1, true ); // Post page to show } @@ -327,7 +327,10 @@ function & get_featured_Item( $restrict_disp = 'posts', $coll_IDs = NULL, $previ // Convert to boolean because settings may have '0' and '1' values instead: $load_featured = (boolean)$load_featured; - if( $featured_list_type !== $load_featured || $featured_disp_detail !== $disp_detail ) + // Check clear disp details without suffix -intro and -nointro: + $check_clear_disp_detail = preg_replace( '#(-intro|-nointro)$#', '', $disp_detail ); + + if( $featured_list_type !== $load_featured || $featured_disp_detail !== $check_clear_disp_detail ) { // Reset a featured list if previous request was to load another type: $FeaturedList = NULL; } @@ -335,7 +338,7 @@ function & get_featured_Item( $restrict_disp = 'posts', $coll_IDs = NULL, $previ // Save current list type in global var: $featured_list_type = $load_featured; // Save current disp detail in global var, but decide 'posts-topcat-intro' and 'posts-topcat-nointro' same as 'posts-topcat' and etc. for other disp details like 'posts-subcat': - $featured_disp_detail = preg_replace( '#(-intro|-nointro)$#', '', $disp_detail ); + $featured_disp_detail = $check_clear_disp_detail; if( !isset( $FeaturedList ) ) { // Don't repeat if we've done this already -- Initialize the featured list only first time this function is called in a skin: @@ -821,7 +824,6 @@ function get_allowed_statuses_condition( $statuses, $dbprefix, $req_blog, $perm_ // init allowed statuses array $allowed_statuses = array(); - $is_logged_in = is_logged_in( false ); $creator_coll_name = ( $dbprefix == 'post_' ) ? $dbprefix.'creator_user_ID' : $dbprefix.'author_user_ID'; // Iterate through all statuses and set allowed to true only if the corresponding status is allowed in case of any post/comments // If the status is not allowed to show, but exists further conditions which may allow it, then set the condition. @@ -834,54 +836,54 @@ function get_allowed_statuses_condition( $statuses, $dbprefix, $req_blog, $perm_ break; case 'community': // It is always allowed for logged in users - $allowed = $is_logged_in; + $allowed = is_logged_in( false ); break; case 'protected': // It is always allowed for members - $allowed = ( $is_logged_in && ( $current_User->check_perm( 'blog_ismember', 1, false, $req_blog ) ) ); + $allowed = check_user_perm( 'blog_ismember', 1, false, $req_blog, false ); break; case 'private': // It is allowed for users who has global 'editall' permission - $allowed = ( $is_logged_in && $current_User->check_perm( 'blogs', 'editall' ) ); + $allowed = check_user_perm( 'blogs', 'editall', false, NULL, false ); if( ! $allowed && $dbprefix == 'comment_' ) { // Allow the private comments for collection owner: - $allowed = ( $is_logged_in && $current_User->check_perm_blogowner( $req_blog ) ); + $allowed = ( is_logged_in( false ) && $current_User->check_perm_blogowner( $req_blog ) ); } - if( !$allowed && $is_logged_in && $current_User->check_perm( $perm_prefix.'private', 'create', false, $req_blog ) ) + if( !$allowed && check_user_perm( $perm_prefix.'private', 'create', false, $req_blog, false ) ) { // Own private posts/comments are allowed if user can create private posts/comments $where[] = ' ( '.$dbprefix."status = 'private' AND ".$creator_coll_name.' = '.$current_User->ID.' ) '; } break; case 'review': // It is allowed for users who have permission to create comments with 'review' status and have at least 'lt' posts/comments edit perm - $allowed = ( $is_logged_in && $current_User->check_perm( $perm_prefix.'review', 'moderate', false, $req_blog ) ); - if( !$allowed && $is_logged_in && $current_User->check_perm( $perm_prefix.'review', 'create', false, $req_blog ) ) + $allowed = check_user_perm( $perm_prefix.'review', 'moderate', false, $req_blog, false ); + if( ! $allowed && check_user_perm( $perm_prefix.'review', 'create', false, $req_blog, false ) ) { // Own posts/comments with 'review' status are allowed if user can create posts/comments with 'review' status $where[] = ' ( '.$dbprefix."status = 'review' AND ".$creator_coll_name.' = '.$current_User->ID.' ) '; } break; case 'draft': // In back-office it is always allowed for users who may create posts/commetns with 'draft' status - $allowed = ( is_admin_page() && $current_User->check_perm( $perm_prefix.'draft', 'create', false, $req_blog ) ); - if( !$allowed && $is_logged_in && $current_User->check_perm( $perm_prefix.'draft', 'create', false, $req_blog ) ) + $allowed = ( is_admin_page() && check_user_perm( $perm_prefix.'draft', 'create', false, $req_blog ) ); + if( ! $allowed && check_user_perm( $perm_prefix.'draft', 'create', false, $req_blog, false ) ) { // In front-office only authors may see their own draft posts/comments, but only if the have permission to create draft posts/comments $where[] = ' ( '.$dbprefix."status = 'draft' AND ".$creator_coll_name.' = '.$current_User->ID.' ) '; } break; case 'deprecated': // In back-office it is always allowed for users who may create posts/comments with 'deprecated' status - $allowed = ( is_admin_page() && $current_User->check_perm( $perm_prefix.'deprecated', 'create', false, $req_blog ) ); + $allowed = ( is_admin_page() && check_user_perm( $perm_prefix.'deprecated', 'create', false, $req_blog ) ); // In front-office it is never allowed break; case 'redirected': // In back-office it is always allowed for users who may create posts/comments with 'deprecated' status - $allowed = ( is_admin_page() && $current_User->check_perm( $perm_prefix.'redirected', 'create', false, $req_blog ) ); + $allowed = ( is_admin_page() && check_user_perm( $perm_prefix.'redirected', 'create', false, $req_blog ) ); // In front-office it is never allowed break; case 'trash': // Currently only users with global editall permissions are allowed to view/delete recycled comments - $allowed = ( ( $dbprefix == 'comment_' ) && is_admin_page() && $current_User->check_perm( 'blogs', 'editall' ) ); + $allowed = ( ( $dbprefix == 'comment_' ) && is_admin_page() && check_user_perm( 'blogs', 'editall' ) ); // In front-office it is never allowed break; @@ -958,7 +960,7 @@ function statuses_where_clause( $show_statuses = NULL, $dbprefix = 'post_', $req if( is_logged_in( false ) && $filter_by_perm ) { // User is logged in and the account was activated - if( $current_User->check_perm( 'blogs', 'editall', false ) ) + if( check_user_perm( 'blogs', 'editall', false ) ) { // User has permission to all blogs posts and comments, we don't have to check blog specific permissions. $allowed_statuses_cond = get_allowed_statuses_condition( $show_statuses, $dbprefix, NULL, $perm_prefix ); if( ! empty( $allowed_statuses_cond ) ) @@ -1228,7 +1230,7 @@ function recreate_autogenerated_excerpts( $continue_url, $remove_all = true, $de */ function cat_select( $Form, $form_fields = true, $show_title_links = true, $params = array() ) { - global $blog, $Blog, $current_blog_ID, $current_User, $edited_Item, $cat_select_form_fields; + global $blog, $Blog, $current_blog_ID, $edited_Item, $cat_select_form_fields; global $admin_url, $rsc_url; if( get_post_cat_setting( $blog ) < 1 ) @@ -1285,7 +1287,7 @@ function cat_select( $Form, $form_fields = true, $show_title_links = true, $para // Init cat display param $cat_display_params = array_merge( $params, array( 'total_count' => 0 ) ); - if( $current_User->check_perm( 'blog_admin', '', false, $blog ) && + if( check_user_perm( 'blog_admin', '', false, $blog ) && ( get_allow_cross_posting() >= 2 || ( isset( $blog) && get_post_cat_setting( $blog ) > 1 && get_allow_cross_posting() == 1 ) ) ) { // If collection cross posting is enabled, go through collections where current Item Type is enabled or current Item already uses categories of those collections: @@ -1305,8 +1307,8 @@ function cat_select( $Form, $form_fields = true, $show_title_links = true, $para foreach( $BlogCache->cache as $l_Blog ) { // Run recursively through the categories of the detected collections: - if( ! $current_User->check_perm( 'blog_post_statuses', 'edit', false, $l_Blog->ID ) || - ! $current_User->check_perm( 'blog_admin', '', false, $l_Blog->ID ) ) + if( ! check_user_perm( 'blog_post_statuses', 'edit', false, $l_Blog->ID ) || + ! check_user_perm( 'blog_admin', '', false, $l_Blog->ID ) ) { // Skip collection if current user has no appropriate permissions: continue; } @@ -1537,7 +1539,7 @@ function cat_select_before_first( $parent_cat_ID, $level ) */ function cat_select_before_each( $cat_ID, $level, $total_count, $params = array() ) { // callback to display sublist element - global $current_blog_ID, $blog, $Blog, $post_extracats, $edited_Item, $current_User; + global $current_blog_ID, $blog, $Blog, $post_extracats, $edited_Item; global $creating, $cat_select_level, $cat_select_form_fields; $params = array_merge( array( @@ -1550,7 +1552,7 @@ function cat_select_before_each( $cat_ID, $level, $total_count, $params = array( $ChapterCache = & get_ChapterCache(); $thisChapter = $ChapterCache->get_by_ID($cat_ID); - if( $thisChapter->lock && !$current_User->check_perm( 'blog_cats', '', false, $current_blog_ID ) ) + if( $thisChapter->lock && ! check_user_perm( 'blog_cats', '', false, $current_blog_ID ) ) { // This chapter is locked and current user has no permission to edit the categories of this blog return; } @@ -1677,14 +1679,14 @@ function cat_select_after_last( $parent_cat_ID, $level ) */ function cat_select_new( & $cat_display_params ) { - global $blog, $Blog, $current_User; + global $blog, $Blog; if( ! $cat_display_params['display_new'] ) { // Don't display an input to create new category: return ''; } - if( ! $current_User->check_perm( 'blog_cats', '', false, $blog ) ) + if( ! check_user_perm( 'blog_cats', '', false, $blog ) ) { // Current user cannot add/edit a categories for this blog return ''; } @@ -1757,7 +1759,7 @@ function cat_select_new( & $cat_display_params ) */ function attach_browse_tabs( $display_tabs3 = true ) { - global $AdminUI, $Collection, $Blog, $current_User, $admin_url, $ItemTypeCache; + global $AdminUI, $Collection, $Blog, $admin_url, $ItemTypeCache; if( empty( $Blog ) ) { // No blog @@ -1766,7 +1768,7 @@ function attach_browse_tabs( $display_tabs3 = true ) $menu_entries = array(); - if( $Blog->get_setting( 'use_workflow' ) && $current_User->check_perm( 'blog_can_be_assignee', 'edit', false, $Blog->ID ) ) + if( $Blog->get_setting( 'use_workflow' ) && check_user_perm( 'blog_can_be_assignee', 'edit', false, $Blog->ID ) ) { // We want to use workflow properties for this blog: $menu_entries['tracker'] = array( 'text' => T_('Workflow view'), @@ -1832,7 +1834,7 @@ function attach_browse_tabs( $display_tabs3 = true ) if( $display_tabs3 ) { - if( $current_User->check_perm( 'blog_comments', 'view', false, $Blog->ID ) ) + if( check_user_perm( 'blog_comments', 'view', false, $Blog->ID ) ) { // User has permission to edit published, draft or deprecated comments (at least one kind) $AdminUI->add_menu_entries( array( 'collections', 'comments' ), array( 'fullview' => array( @@ -1844,7 +1846,7 @@ function attach_browse_tabs( $display_tabs3 = true ) ) ); } - if( $current_User->check_perm( 'meta_comment', 'view', false, $Blog->ID ) ) + if( check_user_perm( 'meta_comment', 'view', false, $Blog->ID ) ) { // Initialize menu entry for Internal comments if current user has a permission: $AdminUI->add_menu_entries( array( 'collections', 'comments' ), array( 'meta' => array( @@ -2080,7 +2082,7 @@ function visibility_select( & $Form, $post_status, $mass_create = false, $labels { $labels = array_merge( get_visibility_statuses('notes-array'), $labels ); - global $current_User, $Collection, $Blog; + global $Collection, $Blog; $mass_create_statuses = array( 'redirected' ); @@ -2088,7 +2090,7 @@ function visibility_select( & $Form, $post_status, $mass_create = false, $labels foreach( $labels as $status => $label ) { - if( $current_User->check_perm( 'blog_post!'.$status, 'create', false, $Blog->ID ) && + if( check_user_perm( 'blog_post!'.$status, 'create', false, $Blog->ID ) && ( !in_array( $status, $mass_create_statuses ) || !$mass_create ) ) { $sharing_options[] = array( $status, $label[0].' '.$label[1].'' ); @@ -2180,7 +2182,7 @@ function load_publish_status( $creating = false ) */ function echo_publish_buttons( $Form, $creating, $edited_Item, $inskin = false, $display_preview = false ) { - global $Collection, $Blog, $current_User, $UserSettings; + global $Collection, $Blog, $UserSettings; global $next_action, $highest_publish_status; // needs to be passed out for echo_publishnowbutton_js( $action ) list( $highest_publish_status, $publish_text ) = get_highest_publish_status( 'post', $Blog->ID, true, '', $edited_Item ); @@ -2254,7 +2256,7 @@ function echo_publish_buttons( $Form, $creating, $edited_Item, $inskin = false, // ---------- SAVE ---------- $save_hotkeys = array( 'ctrl+enter', 'command+enter' ); $next_action = ($creating ? 'create' : 'update'); - if( ! $inskin && $current_User->check_perm( 'item_post!CURSTATUS', 'edit', false, $edited_Item ) ) + if( ! $inskin && check_user_perm( 'item_post!CURSTATUS', 'edit', false, $edited_Item ) ) { // Show Save & Edit only on admin mode $Form->submit( array( 'actionArray['.$next_action.'_edit]', /* TRANS: This is the value of an input submit button */ T_('Save & edit'), 'SaveEditButton btn-status-'.$edited_Item->get( 'status' ), 'data-shortcut' => 'ctrl+s,command+s' ) ); @@ -2432,16 +2434,10 @@ function echo_item_type_change_buttons( $edited_Item, $params = array() ) // JavaScript to set proper Item Type on press button: // Note: We remove all attributes "required" at the press moment in order to avoid HTML5 // restrictions on submit form and allow to change Item Type even with empty fields - echo ''; + $js_config = array( + 'action' => empty( $edited_Item->ID ) ? 'new_item_type' : 'edit_item_type', + ); + expose_var_to_js( 'evo_item_type_change_buttons_config', evo_json_encode( $js_config ) ); } @@ -2581,55 +2577,15 @@ function echo_status_dropdown_button_js( $type = 'post' ) $tooltip_titles_js_array = array(); foreach( $tooltip_titles as $status => $tooltip_title ) { - $tooltip_titles_js_array[] = $status.': \''.TS_( $tooltip_title ).'\''; + $tooltip_titles_js_array[$status] = TS_( $tooltip_title ); } - $tooltip_titles_js_array = implode( ', ', $tooltip_titles_js_array ); - ?> - - get( 'last_select_parent_coll_ID' ) ) ) - { - $default_coll_ID = empty( $Blog ) ? 0 : $Blog->ID; - } -?> - - false, 'use_quick_tags' => false, ), $params ); -?> - - get_cookie_domain(), + 'cookie_path' => get_cookie_path(), + 'crumb_collections_update_tags' => get_crumb( 'collections_update_tags' ), + ); + expose_var_to_js( 'evo_autocomplete_tags_config', evo_json_encode( $autocomplete_params ) ); + + // Initialize per instance/call: + $autocomplete_input_params = array( + 'input_ID' => $params['input_ID'], + 'item_ID' => $params['item_ID'], + 'update_by_ajax' => $params['update_by_ajax'], + 'use_quick_tags' => $params['use_quick_tags'], + + // Default token_input parameters: + 'token_input_params' => array( + 'theme' => 'facebook', + 'queryParam' => 's', + 'propertyToSearch' => 'name', + 'tokenValue' => 'name', + 'preventDuplicates' => true, + 'prePopulate' => NULL, + 'hintText' => T_('Type in a tag'), + 'noResultsText' => T_('No results'), + 'searchingText' => T_('Searching...'), + 'minInputWidth' => 0, + 'jsonContainer' => 'tags', + ), + ); + expose_var_to_js( $params['input_ID'], $autocomplete_input_params, 'evo_autocomplete_input_tags_config' ); } @@ -3682,7 +3470,7 @@ function evo_update_item_tags_by_ajax( item_ID, tags_selector, tag_object, opera */ function check_perm_posttype( $item_typ_ID, $post_extracats, $assert_post_type = true, $assert_permission = true ) { - global $Collection, $Blog, $current_User; + global $Collection, $Blog; $ItemTypeCache = & get_ItemTypeCache(); $ItemType = & $ItemTypeCache->get_by_ID( $item_typ_ID ); @@ -3697,7 +3485,7 @@ function check_perm_posttype( $item_typ_ID, $post_extracats, $assert_post_type = } // Check permission: - return $current_User->check_perm( 'cats_item_type_'.$ItemType->perm_level, 'edit', $assert_permission, $post_extracats ); + return check_user_perm( 'cats_item_type_'.$ItemType->perm_level, 'edit', $assert_permission, $post_extracats ); } @@ -3777,7 +3565,7 @@ function & create_multiple_posts( & $Item, $linebreak = false ) */ function check_cross_posting( & $post_category, & $post_extracats, $prev_main_cat = NULL ) { - global $Messages, $blog, $current_User; + global $Messages, $blog; $result = true; $post_category = param( 'post_category', 'integer', -1 ); @@ -3804,7 +3592,7 @@ function check_cross_posting( & $post_category, & $post_extracats, $prev_main_ca continue; } $cat_blog = get_catblog( $cat ); - if( ( $cat_blog != $post_cat_blog ) && ! ( $allow_cross_posting % 2 == 1 && $current_User->check_perm( 'blog_admin', '', false, $cat_blog ) ) ) + if( ( $cat_blog != $post_cat_blog ) && ! ( $allow_cross_posting % 2 == 1 && check_user_perm( 'blog_admin', '', false, $cat_blog ) ) ) { // this cat is not from the main category $Messages->add( T_('You are not allowed to cross post to several collections.') ); $result = false; @@ -3817,7 +3605,7 @@ function check_cross_posting( & $post_category, & $post_extracats, $prev_main_ca // Check if post_category belongs to a collection different from the previous main cat collection if( $prev_main_cat && ( $prev_cat_blog != $post_cat_blog ) && - ! ( $allow_cross_posting >= 2 && $current_User->check_perm( 'blog_admin', '', false, $prev_cat_blog ) && $current_User->check_perm( 'blog_admin', '', false, $post_cat_blog ) ) ) + ! ( $allow_cross_posting >= 2 && check_user_perm( 'blog_admin', '', false, $prev_cat_blog ) && check_user_perm( 'blog_admin', '', false, $post_cat_blog ) ) ) { $Messages->add( T_('You are not allowed to move post between collections.') ); $result = false; @@ -3900,8 +3688,7 @@ function check_categories( & $post_category, & $post_extracats, $Item = NULL, $f if( ! $post_category || in_array( 0, $post_extracats ) ) // if category key is 0 => means it is a new category { - global $current_User; - if( ! $current_User->check_perm( 'blog_cats', '', false, $Blog->ID ) ) + if( ! check_user_perm( 'blog_cats', '', false, $Blog->ID ) ) { // Current user cannot add a categories for this blog check_categories_nosave( $post_category, $post_extracats, $Item, $from ); // set up the category parameters $Messages->add( T_('You are not allowed to create a new category.'), 'error' ); @@ -3978,8 +3765,8 @@ function check_categories( & $post_category, & $post_extracats, $Item = NULL, $f $ingnored_length = strlen( $ignored_cats ); if( $ingnored_length > 2 ) { // ingnore list is not empty - global $current_User, $admin_url; - if( $current_User->check_perm( 'options', 'view', false ) ) + global $admin_url; + if( check_user_perm( 'options', 'view', false ) ) { $cross_posting_text = ''.T_('cross-posting is disabled').''; } @@ -4051,19 +3838,7 @@ function check_categories_nosave( & $post_category, & $post_extracats, $Item = N */ function echo_onchange_newcat() { -?> - -get_by_ID( $item_ID, false, false ); - if( ! $Item || empty( $current_User ) || ! $current_User->check_perm( 'meta_comment', 'view', false, $blog_ID ) ) + if( ! $Item || ! check_user_perm( 'meta_comment', 'view', false, $blog_ID ) ) { // Current user has no permissions to view internal comments $comment_type = 'feedback'; } @@ -4301,7 +4075,7 @@ function echo_item_comments( $blog_ID, $item_ID, $statuses = NULL, $currentpage */ function echo_comment( $Comment, $redirect_to = NULL, $save_context = false, $inlist_order = NULL, $display_meta_title = false, $reply_level = 0 ) { - global $current_User, $localtimenow, $item_id; + global $localtimenow, $item_id; $Item = & $Comment->get_Item(); $Collection = $Blog = & $Item->get_Blog(); @@ -4333,8 +4107,8 @@ function echo_comment( $Comment, $redirect_to = NULL, $save_context = false, $in } echo '"'.$reply_level_style.'>'; - if( $current_User->check_perm( 'comment!CURSTATUS', 'moderate', false, $Comment ) || - ( $Comment->is_meta() && $current_User->check_perm( 'meta_comment', 'view', false, $Blog->ID ) ) ) + if( check_user_perm( 'comment!CURSTATUS', 'moderate', false, $Comment ) || + ( $Comment->is_meta() && check_user_perm( 'meta_comment', 'view', false, $Blog->ID ) ) ) { // User can moderate this comment OR Comment is meta and current user can view internal comments of the collection: echo '
    '; echo '
    '; @@ -4428,12 +4202,12 @@ function echo_comment( $Comment, $redirect_to = NULL, $save_context = false, $in echo '
    '; $Comment->rating(); $Comment->avatar( 'crop-top-80x80' ); - if( $current_User->check_perm( 'meta_comment', 'edit', false, $Comment ) ) + if( check_user_perm( 'meta_comment', 'edit', false, $Comment ) ) { // Put the comment content into this container to edit by ajax echo '
    '; } $Comment->content( 'htmlbody', 'true' ); - if( $current_User->check_perm( 'meta_comment', 'edit', false, $Comment ) ) + if( check_user_perm( 'meta_comment', 'edit', false, $Comment ) ) { // End of the container that is used to edit internal comment by ajax echo '
    '; } @@ -4681,7 +4455,7 @@ function echo_comment_pages( $item_ID, $currentpage, $comments_number, $params = function check_item_perm_edit( $post_ID, $do_redirect = true ) { global $Messages; - global $Collection, $Blog, $current_User; + global $Collection, $Blog; $user_can_edit = false; @@ -4689,7 +4463,7 @@ function check_item_perm_edit( $post_ID, $do_redirect = true ) { // Check permissions for editing of the current item: $ItemCache = & get_ItemCache (); $edited_Item = $ItemCache->get_by_ID ( $post_ID ); - $user_can_edit = $current_User->check_perm( 'item_post!CURSTATUS', 'edit', false, $edited_Item ); + $user_can_edit = check_user_perm( 'item_post!CURSTATUS', 'edit', false, $edited_Item ); $permission_message = T_('You don\'t have permission to edit this post'); if( $user_can_edit ) @@ -4713,7 +4487,7 @@ function check_item_perm_edit( $post_ID, $do_redirect = true ) else { // Check permissions for creating of a new item: $perm_target = empty( $Blog ) ? NULL : $Blog->ID; - $user_can_edit = $current_User->check_perm( 'blog_post_statuses', 'edit', false, $perm_target ); + $user_can_edit = check_user_perm( 'blog_post_statuses', 'edit', false, $perm_target ); $permission_message = T_('You don\'t have permission to post into this blog'); } @@ -4769,8 +4543,7 @@ function check_item_perm_create( $check_Blog = NULL ) } else { // Check permissions for current user - global $current_User; - return $current_User->check_perm( 'blog_post_statuses', 'edit', false, $check_Blog->ID ); + return check_user_perm( 'blog_post_statuses', 'edit', false, $check_Blog->ID ); } return true; @@ -5493,7 +5266,7 @@ function items_manual_results_block( $params = array() ) return; } - global $current_User, $blog, $Collection, $Blog, $admin_url, $Session; + global $blog, $Collection, $Blog, $admin_url, $Session; $result_fadeout = $Session->get( 'fadeout_array' ); @@ -5542,7 +5315,7 @@ function items_manual_results_block( $params = array() ) $ChapterCache = & get_ChapterCache(); if( $updated_Chapter = & $ChapterCache->get_by_ID( $order_obj_ID, false ) ) { - if( $current_User->check_perm( 'blog_cats', '', false, $updated_Chapter->blog_ID ) ) + if( check_user_perm( 'blog_cats', '', false, $updated_Chapter->blog_ID ) ) { // Check permission to edit this Chapter $updated_Chapter->set( 'order', intval( $new_value ) ); $updated_Chapter->dbupdate(); @@ -5556,7 +5329,7 @@ function items_manual_results_block( $params = array() ) $ItemCache = & get_ItemCache(); if( $updated_Item = & $ItemCache->get_by_ID( $order_obj_ID, false ) ) { - if( $current_User->check_perm( 'item_post!CURSTATUS', 'edit', false, $updated_Item ) ) + if( check_user_perm( 'item_post!CURSTATUS', 'edit', false, $updated_Item ) ) { // Check permission to edit this Item $updated_Item->update_order( $new_value, $cat_ID ); } @@ -5658,13 +5431,7 @@ function items_created_results_block( $params = array() ) 'action' => '', ), $params ); - if( !is_logged_in() ) - { // Only logged in users can access to this function - return; - } - - global $current_User; - if( !$current_User->check_perm( 'users', 'moderate' ) ) + if( ! check_user_perm( 'users', 'moderate' ) ) { // Check minimum permission: return; } @@ -5752,13 +5519,7 @@ function items_edited_results_block( $params = array() ) 'results_no_text' => T_('User has not edited any posts'), ), $params ); - if( !is_logged_in() ) - { // Only logged in users can access to this function - return; - } - - global $current_User; - if( !$current_User->check_perm( 'users', 'moderate' ) ) + if( ! check_user_perm( 'users', 'moderate' ) ) { // Check minimum permission: return; } @@ -6024,7 +5785,7 @@ function get_item_version_title( $Version ) */ function items_results( & $items_Results, $params = array() ) { - global $Collection, $Blog, $current_User; + global $Collection, $Blog; // Make sure we are not missing any param: $params = array_merge( array( @@ -6048,7 +5809,7 @@ function items_results( & $items_Results, $params = array() ) ), $params ); if( $params['display_selector'] && - is_logged_in() && $current_User->check_perm( 'blog_post_statuses', 'edit', false, $Blog->ID ) ) + check_user_perm( 'blog_post_statuses', 'edit', false, $Blog->ID ) ) { // Display item selector only if current User has a permission to edit: $items_Results->cols[] = array( 'th' => '', @@ -6075,7 +5836,7 @@ function items_results( & $items_Results, $params = array() ) 'text' => get_mass_change_renderer_buttons( 'btn-xs' ), ), ); - if( is_pro() && is_logged_in() && $current_User->check_perm( 'options', 'edit' ) ) + if( is_pro() && check_user_perm( 'options', 'edit' ) ) { // Export Items only for PRO version: $items_Results->list_mass_actions['mass_export'] = array( 'type' => 'submit', @@ -6224,9 +5985,9 @@ function items_results( & $items_Results, $params = array() ) */ function item_type_global_icons( $object_Widget ) { - global $current_User, $admin_url, $DB, $Collection, $Blog, $Session; + global $admin_url, $DB, $Collection, $Blog, $Session; - if( is_logged_in() && ! empty( $Blog ) && $current_User->check_perm( 'blog_post_statuses', 'edit', false, $Blog->ID ) ) + if( ! empty( $Blog ) && check_user_perm( 'blog_post_statuses', 'edit', false, $Blog->ID ) ) { // We have permission to add a post with at least one status: $tab_type = ( get_param( 'tab' ) == 'type' ) ? get_param( 'tab_type' ) : ''; @@ -6256,8 +6017,8 @@ function item_type_global_icons( $object_Widget ) $icon_group_create_mass = NULL; } - if( $current_User->check_perm( 'admin', 'normal' ) && - $current_User->check_perm( 'options', 'edit' ) ) + if( check_user_perm( 'admin', 'normal' ) && + check_user_perm( 'options', 'edit' ) ) { // Icon buttons for import: $import_buttons = array( 'xml' => array( @@ -6322,7 +6083,7 @@ function item_type_global_icons( $object_Widget ) foreach( $item_types as $item_type ) { - if( $current_User->check_perm( 'blog_item_type_'.$item_type->perm_level, 'edit', false, $Blog->ID ) ) + if( check_user_perm( 'blog_item_type_'.$item_type->perm_level, 'edit', false, $Blog->ID ) ) { // We have the permission to create posts with this post type: $object_Widget->global_icon( T_('Create multiple posts...'), 'new', $admin_url.'?ctrl=items&action=new_mass&blog='.$Blog->ID.'&item_typ_ID='.$item_type->ID, @@ -6560,7 +6321,7 @@ function display_mass_items_confirmation_panel() */ function task_title_link( $Item, $display_flag = true, $display_status = false ) { - global $current_User, $admin_url; + global $admin_url; $col = ''; if( $display_status && is_logged_in() ) @@ -6614,7 +6375,7 @@ function task_title_link( $Item, $display_flag = true, $display_status = false ) $col .= ' '; } - if( $current_User->check_perm( 'meta_comment', 'view', false, $Item->get_blog_ID() ) ) + if( check_user_perm( 'meta_comment', 'view', false, $Item->get_blog_ID() ) ) { // Display icon of internal comments Only if current user can views internal comments: $metas_count = generic_ctp_number( $Item->ID, 'metas', 'total' ); if( $metas_count > 0 ) @@ -6678,7 +6439,7 @@ function item_row_slug( $item_slug ) */ function item_row_status( $Item, $index, $cat_ID = NULL ) { - global $current_User, $AdminUI, $Collection, $admin_url; + global $AdminUI, $Collection, $admin_url; $Item->load_Blog(); $blog_ID = $Item->Blog->ID; @@ -6688,7 +6449,7 @@ function item_row_status( $Item, $index, $cat_ID = NULL ) // Get allowed visibility statuses $status_options = get_visibility_statuses( '', $exclude_statuses ); - if( is_logged_in() && $current_User->check_perm( 'item_post!CURSTATUS', 'edit', false, $Item ) && + if( check_user_perm( 'item_post!CURSTATUS', 'edit', false, $Item ) && isset( $AdminUI, $AdminUI->skin_name ) && $AdminUI->skin_name == 'bootstrap' && !empty( $status_options ) ) { // Use dropdown for bootstrap skin and if current user can edit this post $status_icon_options = get_visibility_statuses( 'icons', $exclude_statuses ); @@ -6726,7 +6487,7 @@ function item_row_status( $Item, $index, $cat_ID = NULL ) */ function item_row_order( $Item ) { - global $current_User, $ItemList, $Blog; + global $ItemList, $Blog; if( isset( $ItemList, $ItemList->filters['cat_single'] ) && ! empty( $ItemList->filters['cat_single'] ) ) @@ -6754,7 +6515,7 @@ function item_row_order( $Item ) { // Don't allow to edit order because in such case we display a sum of orders from all extra categories of the Item: return ''.$item_order.''; } - elseif( is_logged_in() && $current_User->check_perm( 'item_post!CURSTATUS', 'edit', false, $Item ) ) + elseif( check_user_perm( 'item_post!CURSTATUS', 'edit', false, $Item ) ) { // If current user can edit the Item then allow to edit an order by AJAX: return ''.( $item_order === NULL ? '-' : $item_order ).''; } @@ -6773,9 +6534,7 @@ function item_row_order( $Item ) */ function item_row_checkbox( $Item ) { - global $current_User; - - if( is_logged_in() && $current_User->check_perm( 'item_post!CURSTATUS', 'edit', false, $Item ) ) + if( check_user_perm( 'item_post!CURSTATUS', 'edit', false, $Item ) ) { // Allow to select Item only if current User can edit it: return ''; } @@ -6789,7 +6548,7 @@ function item_row_checkbox( $Item ) */ function item_edit_actions( $Item ) { - global $admin_url, $blog, $current_User; + global $admin_url, $blog; $r = ''; @@ -6809,7 +6568,7 @@ function item_edit_actions( $Item ) 'title' => '#', 'class' => '' ) ); - if( is_pro() && is_logged_in() && $current_User->check_perm( 'options', 'edit' ) ) + if( is_pro() && check_user_perm( 'options', 'edit' ) ) { // Export Item only for PRO version: $r .= action_icon( T_('Export this Item...'), 'download', $admin_url.'?ctrl=exportxml&action=export_item&blog_ID='.$blog.'&item_ID='.$Item->ID.'&'.url_crumb( 'item' ) ); @@ -6874,7 +6633,7 @@ function manual_display_chapters( $params = array() ) */ function manual_display_chapter_row( $Chapter, $level, $params = array() ) { - global $line_class, $current_User, $Settings; + global $line_class, $Settings; global $admin_url; global $Session; @@ -6886,8 +6645,8 @@ function manual_display_chapter_row( $Chapter, $level, $params = array() ) $line_class = $line_class == 'even' ? 'odd' : 'even'; - $perm_edit = $current_User->check_perm( 'blog_cats', '', false, $Chapter->blog_ID ); - $perm_create_item = $current_User->check_perm( 'blog_post_statuses', 'edit', false, $Chapter->blog_ID ); + $perm_edit = check_user_perm( 'blog_cats', '', false, $Chapter->blog_ID ); + $perm_create_item = check_user_perm( 'blog_post_statuses', 'edit', false, $Chapter->blog_ID ); // Redirect to manual pages after adding/editing chapter $redirect_page = '&redirect_page=manual'; @@ -6990,7 +6749,7 @@ function manual_display_chapter_row( $Chapter, $level, $params = array() ) */ function manual_display_post_row( $Item, $level, $params = array() ) { - global $line_class, $current_User, $Settings; + global $line_class, $Settings; global $admin_url; global $Session; @@ -7052,7 +6811,7 @@ function manual_display_post_row( $Item, $level, $params = array() ) 'post_navigation' => 'same_category', // set a navigating through category 'nav_target' => $params['chapter_ID'], // set the category ID as nav target ) ) ); - if( $current_User->check_perm( 'slugs', 'view', false ) ) + if( check_user_perm( 'slugs', 'view', false ) ) { // Display icon to view all slugs of this item if current user has permission $r .= ' '.action_icon( T_('Edit slugs').'...', 'edit', $admin_url.'?ctrl=slugs&slug_item_ID='.$Item->ID ); } @@ -7066,7 +6825,7 @@ function manual_display_post_row( $Item, $level, $params = array() ) $order_value = T_('Alphabetic'); if( isset( $params['cat_order'] ) && $params['cat_order'] == 'manual' ) { - if( $current_User->check_perm( 'item_post!CURSTATUS', 'edit', false, $Item ) ) + if( check_user_perm( 'item_post!CURSTATUS', 'edit', false, $Item ) ) { // Add availability to edit an order if current user can edit this item $order_attrs .= ' id="order-item-'.$Item->ID.'" data-cat="'.$params['chapter_ID'].'" title="'.format_to_output( T_('Click to change an order'), 'htmlattr' ).'"'; } @@ -7093,8 +6852,6 @@ function manual_display_post_row( $Item, $level, $params = array() ) */ function item_td_task_cell( $type, $Item, $editable = true ) { - global $current_User; - switch( $type ) { case 'priority': @@ -7130,7 +6887,7 @@ function item_td_task_cell( $type, $Item, $editable = true ) $title = ''; } - if( $current_User && $current_User->check_perm( 'item_post!CURSTATUS', 'edit', false, $Item ) && $editable ) + if( $editable && check_user_perm( 'item_post!CURSTATUS', 'edit', false, $Item ) ) { // Current user can edit this item return ''.$title.''; } @@ -7151,13 +6908,11 @@ function item_td_task_cell( $type, $Item, $editable = true ) */ function item_td_task_class( $post_ID, $post_pst_ID, $editable_class ) { - global $current_User; - $ItemCache = & get_ItemCache(); $Item = & $ItemCache->get_by_ID( $post_ID ); $class = 'shrinkwrap tskst_'.$post_pst_ID; - if( $current_User->check_perm( 'item_post!CURSTATUS', 'edit', false, $Item ) ) + if( check_user_perm( 'item_post!CURSTATUS', 'edit', false, $Item ) ) { // Current user can edit this item, Add a class to edit a priority by click from view list $class .= ' '.$editable_class; } diff --git a/inc/items/model/_itemlight.class.php b/inc/items/model/_itemlight.class.php index 6a040e36349..ac730b18ce8 100644 --- a/inc/items/model/_itemlight.class.php +++ b/inc/items/model/_itemlight.class.php @@ -120,6 +120,15 @@ class ItemLight extends DataObject */ var $tags = NULL; + /** + * Array of checklist lines + * + * Lazy loaded. + * @see ItemLight::get_checklist_lines() + * @var array + */ + var $checklist_lines = NULL; + /** * Array of dbchanges flag to be able to check modifications, and execute update queries only when required * Note: Only those updates needs to be tracked in this var which are saved in a relational table ( e.g. tags, extracats ) @@ -146,7 +155,7 @@ function __construct( $db_row = NULL, $dbtable = 'T_items__item', $dbprefix = 'p $datecreated_field = '', $datemodified_field = 'datemodified', $creator_field = '', $lasteditor_field = '' ) { - global $localtimenow, $default_locale, $current_User; + global $localtimenow, $default_locale; // Call parent constructor: parent::__construct( $dbtable, $dbprefix, $dbIDname, $datecreated_field, $datemodified_field, @@ -214,6 +223,7 @@ static function get_delete_cascades() array( 'table'=>'T_items__subscriptions', 'fk'=>'isub_item_ID', 'msg'=>T_('%d items subscriptions') ), array( 'table'=>'T_items__prerendering', 'fk'=>'itpr_itm_ID', 'msg'=>T_('%d prerendered content') ), array( 'table'=>'T_items__user_data', 'fk'=>'itud_item_ID', 'msg'=>T_('%d recordings of user data for a specific post') ), + array( 'table'=>'T_items__checklist_lines', 'fk'=>'check_item_ID', 'msg'=>T_('%d checklist items') ), ); } @@ -946,8 +956,8 @@ function & get_main_Chapter() } else { // Main chapter is defined, we can show the page - global $Messages, $current_User; - if( is_logged_in() && $current_User->check_perm( 'blogs', 'editall' ) ) + global $Messages; + if( check_user_perm( 'blogs', 'editall' ) ) { // User has permission to all blogs posts and comments, display a message as note in order to allow update it $message_type = 'note'; } @@ -1569,7 +1579,7 @@ function get_title( $params = array() ) { // This is an intro, do not link title by default: $params['link_type'] = 'none'; } - elseif( is_single_page() ) + elseif( is_single_page( $this->ID ) ) { // We are on the single url already: $params['link_type'] = 'none'; } @@ -1897,6 +1907,49 @@ function & get_tags() } + /** + * Get array of checklist lines. + * + * @return array + */ + function get_checklist_lines() + { + global $DB; + + if( ! isset( $this->checklist_lines ) ) + { + // Build query to get the checklist lines: + $checklist_SQL = new SQL( 'Get checklist lines for Item #'.$this->ID ); + $checklist_SQL->SELECT( 'check_ID, check_item_ID, check_checked, check_label, check_order' ); + $checklist_SQL->FROM( 'T_items__checklist_lines' ); + $checklist_SQL->WHERE( 'check_item_ID = '.$DB->quote( $this->ID ) ); + $checklist_SQL->ORDER_BY( 'check_order ASC, check_ID ASC' ); + $this->checklist_lines = $DB->get_results( $checklist_SQL ); + } + + return $this->checklist_lines; + } + + + /** + * Get number of unchecked checklist lines + */ + function get_unchecked_checklist_lines() + { + $checklist_lines = $this->get_checklist_lines(); + $unchecked_checklist_lines = 0; + foreach( $checklist_lines as $checklist_line ) + { + if( ! $checklist_line->check_checked ) + { + $unchecked_checklist_lines++; + } + } + + return $unchecked_checklist_lines; + } + + /** * Get a list of item IDs from $MainList and $ItemList, if they are loaded. * This is used for prefetching item related data for the whole list(s). @@ -1935,9 +1988,10 @@ function get_history_link( $params = array() ) 'after' => '', 'link_text' => '$icon$', // Use a mask $icon$ or some other text 'class' => '', + 'check_perm' => true, // FALSE - if this link must be displayed even if current has no permission to view item history page ), $params ); - if( ( $history_url = $this->get_history_url() ) === false ) + if( ( $history_url = $this->get_history_url( '&', $params['check_perm'] ) ) === false ) { // No url available for current user, Don't display a link return; } @@ -1957,11 +2011,11 @@ function get_history_link( $params = array() ) * @param string Glue between url params * @return string|boolean URL to history OR False when user cannot see a history */ - function get_history_url( $glue = '&' ) + function get_history_url( $glue = '&', $check_perm = true ) { - global $current_User, $admin_url; + global $admin_url; - if( ! is_logged_in() || ! $current_User->check_perm( 'item_post!CURSTATUS', 'edit', false, $this ) ) + if( $check_perm && ! check_user_perm( 'item_post!CURSTATUS', 'edit', false, $this ) ) { // Current user cannot see a history return false; } diff --git a/inc/items/model/_itemlist.class.php b/inc/items/model/_itemlist.class.php index afeb03e1cd0..919638936a1 100644 --- a/inc/items/model/_itemlist.class.php +++ b/inc/items/model/_itemlist.class.php @@ -640,8 +640,11 @@ function & get_prevnext_Item( $direction = 'next', $itemtype_usage = '', $featur $next_Query->where_assignees( $this->filters['assignees'] ); $next_Query->where_assignees_logins( $this->filters['assignees_login'] ); $next_Query->where_author_assignee( $this->filters['author_assignee'] ); + $next_Query->where_involves( $this->filters['involves'] ); + $next_Query->where_involves_logins( $this->filters['involves_login'] ); $next_Query->where_locale( $this->filters['lc'] ); $next_Query->where_statuses( $this->filters['statuses'] ); + $next_Query->where_statuses_array( $this->filters['statuses_array'] ); // itemtype_usage param is kept only for the case when some custom types should be displayed $next_Query->where_itemtype_usage( ! empty( $itemtype_usage ) ? $itemtype_usage : $this->filters['itemtype_usage'] ); $next_Query->where_keywords( $this->filters['keywords'], $this->filters['phrase'], $this->filters['exact'] ); @@ -655,6 +658,7 @@ function & get_prevnext_Item( $direction = 'next', $itemtype_usage = '', $featur $next_Query->where_flagged( $this->filters['flagged'] ); $next_Query->where_locale_visibility(); $next_Query->where_mustread( $this->filters['mustread'] ); + $next_Query->where_renderers( $this->filters['renderers'] ); /* * ORDER BY stuff: diff --git a/inc/items/model/_itemlistlight.class.php b/inc/items/model/_itemlistlight.class.php index 20c9f59cdb9..2c40124bb76 100644 --- a/inc/items/model/_itemlistlight.class.php +++ b/inc/items/model/_itemlistlight.class.php @@ -136,6 +136,8 @@ function __construct( 'assignees' => NULL, 'assignees_login' => NULL, 'author_assignee' => NULL, + 'involves' => NULL, + 'involves_login' => NULL, 'lc' => 'all', // Filter on requested locale 'keywords' => NULL, 'keyword_scope' => 'title,content', // What fields are used for searching: 'title', 'content' @@ -149,6 +151,7 @@ function __construct( 'ymdhms_min' => NULL, 'ymdhms_max' => NULL, 'statuses' => NULL, + 'statuses_array' => NULL, 'types' => NULL, // Filter by item type IDs (separated by comma) 'itemtype_usage' => 'post', // Filter by item type usage (separated by comma): post, page, intro-front, intro-main, intro-cat, intro-tag, intro-sub, intro-all, special 'visibility_array' => get_inskin_statuses( is_null( $this->Blog ) ? NULL : $this->Blog->ID, 'post' ), @@ -158,6 +161,7 @@ function __construct( 'posts' => $this->limit, 'page' => 1, 'featured' => NULL, + 'renderers' => NULL, ) ); } @@ -261,6 +265,14 @@ function set_filters( $filters, $memorize = true, $use_previous_filters = false */ memorize_param( $this->param_prefix.'author_assignee', 'string', $this->default_filters['author_assignee'], $this->filters['author_assignee'] ); + /* + * Restrict to selected involves: + */ + // List of involved user IDs to restrict to + memorize_param( $this->param_prefix.'involves', 'string', $this->default_filters['involves'], $this->filters['involves'] ); + // List of involved user logins to restrict to + memorize_param( $this->param_prefix.'involves_login', 'string', $this->default_filters['involves_login'], $this->filters['involves_login'] ); + /* * Restrict to selected locale: */ @@ -270,6 +282,7 @@ function set_filters( $filters, $memorize = true, $use_previous_filters = false * Restrict to selected statuses: */ memorize_param( $this->param_prefix.'status', 'string', $this->default_filters['statuses'], $this->filters['statuses'] ); // List of statuses to restrict to + memorize_param( $this->param_prefix.'statuses', 'array:string', $this->default_filters['statuses_array'], $this->filters['statuses_array'] ); // Array of statuses to restrict to /* * Restrict to selected post type: @@ -321,6 +334,11 @@ function set_filters( $filters, $memorize = true, $use_previous_filters = false // Note: oftentimes, $show_statuses will have been preset to a more restrictive set of values memorize_param( $this->param_prefix.'show_statuses', 'array', $this->default_filters['visibility_array'], $this->filters['visibility_array'] ); // Array of sharings to restrict to + /* + * Restrict to selected renderer plugins: + */ + memorize_param( $this->param_prefix.'renderers', 'array:string', $this->default_filters['renderers'], $this->filters['renderers'] ); + /* * OLD STYLE orders: */ @@ -397,7 +415,9 @@ function load_from_Request( $use_filters = true ) $cat = param( 'cat', '/^[*\-\|]?([0-9]+(,[0-9]+)*)?$/', $this->default_filters['cat_modifier'], true ); // List of cats to restrict to $catsel = param( 'catsel', 'array:integer', $this->default_filters['cat_array'], true ); // Array of cats to restrict to - if( empty( $catsel ) && preg_match( '~^[0-9]+$~', $cat ) ) + if( ( empty( $catsel ) || // 'catsel' multicats filter is not defined + ( is_array( $catsel ) && count( $catsel ) == 1 ) // 'catsel' filter is used for single cat, e.g. when skin config 'cat_array_mode' = 'parent' + ) && preg_match( '~^[0-9]+$~', $cat ) ) // 'cat' filter is ID of category and NOT modifier for 'catsel' multicats { // We are on a single cat page: (equivalent to $disp_detail == 'posts-topcat') // NOTE: we must have selected EXACTLY ONE CATEGORY through the cat parameter // BUT: - this can resolve to including children @@ -445,6 +465,15 @@ function load_from_Request( $use_filters = true ) $this->filters['author_assignee'] = param( $this->param_prefix.'author_assignee', '/^[0-9]+$/', $this->default_filters['author_assignee'], true ); + /* + * Restrict to selected involves: + */ + // List of involved user IDs to restrict to + $this->filters['involves'] = param( $this->param_prefix.'involves', '/^-?[0-9]+(,[0-9]+)*$/', $this->default_filters['involves'], true ); + // List of involved user logins to restrict to + $this->filters['involves_login'] = param( $this->param_prefix.'involves_login', '/^-?[A-Za-z0-9_\.]+(,[A-Za-z0-9_\.]+)*$/', $this->default_filters['involves_login'], true ); + + /* * Restrict to selected locale: */ @@ -455,6 +484,7 @@ function load_from_Request( $use_filters = true ) * Restrict to selected statuses: */ $this->filters['statuses'] = param( $this->param_prefix.'status', '/^(-|-[0-9]+|[0-9]+)(,[0-9]+)*$/', $this->default_filters['statuses'], true ); // List of statuses to restrict to + $this->filters['statuses_array'] = param( $this->param_prefix.'statuses', 'array:string', $this->default_filters['statuses_array'], true ); // Array of statuses to restrict to /* * Restrict to selected types: @@ -536,6 +566,11 @@ function load_from_Request( $use_filters = true ) $this->filters['visibility_array'] = param( $this->param_prefix.'show_statuses', 'array:string', $this->default_filters['visibility_array'] , true, false, true, false ); // Array of sharings to restrict to + /* + * Restrict to selected renderer plugins: + */ + $this->filters['renderers'] = param( $this->param_prefix.'renderers', 'array:string', $this->default_filters['renderers'], true ); + /* * Ordering: */ @@ -584,8 +619,6 @@ function load_from_Request( $use_filters = true ) */ function query_init() { - global $current_User; - // Call reset to init the ItemQuery // This prevents from adding the same conditions twice if the ItemQuery was already initialized $this->reset(); @@ -627,8 +660,11 @@ function query_init() $this->ItemQuery->where_assignees( $this->filters['assignees'] ); $this->ItemQuery->where_assignees_logins( $this->filters['assignees_login'] ); $this->ItemQuery->where_author_assignee( $this->filters['author_assignee'] ); + $this->ItemQuery->where_involves( $this->filters['involves'] ); + $this->ItemQuery->where_involves_logins( $this->filters['involves_login'] ); $this->ItemQuery->where_locale( $this->filters['lc'] ); $this->ItemQuery->where_statuses( $this->filters['statuses'] ); + $this->ItemQuery->where_statuses_array( $this->filters['statuses_array'] ); $this->ItemQuery->where_types( $this->filters['types'] ); $this->ItemQuery->where_itemtype_usage( $this->filters['itemtype_usage'] ); $this->ItemQuery->where_keywords( $this->filters['keywords'], $this->filters['phrase'], $this->filters['exact'], $this->filters['keyword_scope'] ); @@ -646,6 +682,7 @@ function query_init() $this->ItemQuery->where_locale_visibility(); } $this->ItemQuery->where_mustread( $this->filters['mustread'] ); + $this->ItemQuery->where_renderers( $this->filters['renderers'] ); /* @@ -890,8 +927,11 @@ function get_lastpostdate($dateformat = 'Y-m-d H:i:s') $lastpost_ItemQuery->where_author_logins( $this->filters['authors_login'] ); $lastpost_ItemQuery->where_assignees( $this->filters['assignees'] ); $lastpost_ItemQuery->where_assignees_logins( $this->filters['assignees_login'] ); + $lastpost_ItemQuery->where_involves( $this->filters['involves'] ); + $lastpost_ItemQuery->where_involves_logins( $this->filters['involves_login'] ); $lastpost_ItemQuery->where_locale( $this->filters['lc'] ); $lastpost_ItemQuery->where_statuses( $this->filters['statuses'] ); + $lastpost_ItemQuery->where_statuses_array( $this->filters['statuses_array'] ); $lastpost_ItemQuery->where_types( $this->filters['types'] ); $lastpost_ItemQuery->where_itemtype_usage( $this->filters['itemtype_usage'] ); $lastpost_ItemQuery->where_keywords( $this->filters['keywords'], $this->filters['phrase'], $this->filters['exact'], $this->filters['keyword_scope'] ); @@ -901,6 +941,7 @@ function get_lastpostdate($dateformat = 'Y-m-d H:i:s') $this->filters['ts_min'], $this->filters['ts_max'] ); $lastpost_ItemQuery->where_visibility( $this->filters['visibility_array'] ); $lastpost_ItemQuery->where_locale_visibility(); + $lastpost_ItemQuery->where_renderers( $this->filters['renderers'] ); /* * order by stuff: @@ -975,6 +1016,7 @@ function get_filter_titles( $ignore = array(), $params = array() ) 'display_status' => true, 'status_text' => T_('Status').': ', 'statuses_text' => T_('Statuses').': ', + 'statuses_nor_text' => T_('All but '), 'display_itemtype' => true, 'type_text' => T_('Item Type').': ', @@ -986,12 +1028,20 @@ function get_filter_titles( $ignore = array(), $params = array() ) 'display_assignee' => true, 'assignes_text' => T_('Assigned to').': ', + 'display_involves' => true, + 'involves_text' => T_('Involves').': ', + 'involves_nor_text' => T_('All involves except').': ', + 'display_locale' => true, 'display_time' => true, 'display_limit' => true, 'display_flagged' => true, 'display_mustread' => true, + 'display_renderer' => true, + 'renderer_text' => T_('Renderer').': ', + 'renderers_text' => T_('Renderers').': ', + 'group_mask' => '$group_title$$filter_items$', // $group_title$, $filter_items$ 'filter_mask' => '"$filter_name$"', // $group_title$, $filter_name$, $clear_icon$ 'filter_mask_nogroup' => '"$filter_name$"', // $filter_name$, $clear_icon$ @@ -1322,6 +1372,55 @@ function get_filter_titles( $ignore = array(), $params = array() ) } + // INVOLVES: + if( $params['display_involves'] ) + { + if( ! empty( $this->filters['involves'] ) || ! empty( $this->filters['involves_login'] ) ) + { + $involves = trim( $this->filters['involves'].','.get_users_IDs_by_logins( $this->filters['involves_login'] ), ',' ); + $exclude_involves = false; + if( substr( $involves, 0, 1 ) == '-' ) + { // Authors are excluded + $involves = substr( $involves, 1 ); + $exclude_involves = true; + } + $involves = preg_split( '~\s*,\s*~', $involves, -1, PREG_SPLIT_NO_EMPTY ); + $involves_names = array(); + if( $involves ) + { + $UserCache = & get_UserCache(); + $filter_class_i = ( $filter_class_i > count( $filter_classes ) - 1 ) ? 0 : $filter_class_i; + foreach( $involves as $involves_ID ) + { + if( $tmp_User = $UserCache->get_by_ID( $involves_ID, false, false ) ) + { + $user_clear_icon = $clear_icon ? action_icon( T_('Remove this filter'), 'remove', regenerate_url( $this->param_prefix.'involves='.$involves_ID ) ) : ''; + $involves_names[] = str_replace( array( '$group_title$', '$filter_name$', '$clear_icon$', '$filter_class$' ), + array( $params['involves_text'], $tmp_User->get( 'login' ), $user_clear_icon, $filter_classes[ $filter_class_i ] ), + $params['filter_mask'] ); + } + } + $filter_class_i++; + } + if( count( $involves_names ) > 0 ) + { // Display info of filter by involves + if( $exclude_involves ) + { // Exclude involves + $involves_names_string = $params['involves_nor_text'].implode( $params['separator_nor'], $involves_names ); + } + else + { // Filter by involves + $involves_names_string = implode( $params['separator_comma'], $involves_names ); + } + + $title_array[] = str_replace( array( '$group_title$', '$filter_items$' ), + array( $params['involves_text'], $params['before_items'].$involves_names_string.$params['after_items'] ), + $params['group_mask'] ); + } + } + } + + // LOCALE: if( $params['display_locale'] ) { @@ -1340,41 +1439,72 @@ function get_filter_titles( $ignore = array(), $params = array() ) } - // EXTRA STATUSES: + // EXTRA(WORKFLOW/TASK) STATUSES: if( $params['display_status'] ) { - if( !empty($this->filters['statuses']) ) + if( ! empty( $this->filters['statuses'] ) || ! empty( $this->filters['statuses_array'] ) ) { $filter_class_i = ( $filter_class_i > count( $filter_classes ) - 1 ) ? 0 : $filter_class_i; - if( $this->filters['statuses'] == '-' ) - { - $status_clear_icon = $clear_icon ? action_icon( T_('Remove this filter'), 'remove', regenerate_url( $this->param_prefix.'status=-' ) ) : ''; - $title_array[] = str_replace( array( '$filter_name$', '$clear_icon$', '$filter_class$' ), - array( T_('Without status'), $status_clear_icon, $filter_classes[ $filter_class_i ] ), - $params['filter_mask_nogroup'] ); + if( isset( $this->filters['statuses_array'] ) && + is_array( $this->filters['statuses_array'] ) && + ! empty( $this->filters['statuses_array'] ) ) + { // Filter by array of statuses is used currently: + $filter_statuses = $this->filters['statuses_array']; + $filter_status_param = $this->param_prefix.'statuses'; + $task_status_separator = $params['separator_or']; + $task_status_prefix = ''; + } + elseif( ! empty( $this->filters['statuses'] ) ) + { // Filter by list/string of statuses is used currently: + $filter_statuses = explode( ',', $this->filters['statuses'] ); + $filter_status_param = $this->param_prefix.'status'; + if( strlen( $filter_statuses[0] ) > 1 && + substr( $filter_statuses[0], 0, 1 ) == '-' ) + { // Filter to exclude by statuses: + $filter_statuses[0] = substr( $filter_statuses[0], 1 ); + $task_status_separator = $params['separator_nor']; + $task_status_prefix = $params['statuses_nor_text']; + $params['status_text'] = $params['statuses_text']; + } + else + { // Filter to include by statuses: + $task_status_separator = $params['separator_or']; + $task_status_prefix = ''; + } } else + { // No filters by status: + $filter_statuses = array(); + } + $ItemStatusCache = & get_ItemStatusCache(); + $task_status_titles = array(); + foreach( $filter_statuses as $filter_status ) { - $status_IDs = explode( ',', $this->filters['statuses'] ); - $ItemStatusCache = & get_ItemStatusCache(); - $statuses = array(); - foreach( $status_IDs as $status_ID ) - { - if( $ItemStatus = & $ItemStatusCache->get_by_ID( $status_ID ) ) - { - $status_clear_icon = $clear_icon ? action_icon( T_('Remove this filter'), 'remove', regenerate_url( $this->param_prefix.'status='.$status_ID ) ) : ''; - $statuses[] = str_replace( array( '$group_title$', '$filter_name$', '$clear_icon$', '$filter_class$' ), - array( $params['status_text'], $ItemStatus->get_name(), $status_clear_icon, $filter_classes[ $filter_class_i ] ), - $params['filter_mask'] ); - } + if( $filter_status == '-' ) + { // Without status: + $status_clear_icon = $clear_icon ? action_icon( T_('Remove this filter'), 'remove', regenerate_url( $filter_status_param.'=-' ) ) : ''; + $task_status_titles[] = str_replace( array( '$filter_name$', '$clear_icon$', '$filter_class$' ), + array( T_('Without status'), $status_clear_icon, $filter_classes[ $filter_class_i ] ), + $params['filter_mask_nogroup'] ); } - $title_array[] = str_replace( array( '$group_title$', '$filter_items$' ), - ( ( count( $statuses ) > 1 ) ? - array( $params['statuses_text'], $params['before_items'].implode( $params['separator_comma'], $statuses ).$params['after_items'] ): - array( $params['status_text'], implode( $params['separator_comma'], $statuses ) ) ), + elseif( $ItemStatus = & $ItemStatusCache->get_by_ID( $filter_status, false, false ) ) + { // Specific status: + $status_clear_icon = $clear_icon ? action_icon( T_('Remove this filter'), 'remove', regenerate_url( $filter_status_param.'='.$ItemStatus->ID ) ) : ''; + $task_status_titles[] = str_replace( array( '$group_title$', '$filter_name$', '$clear_icon$', '$filter_class$' ), + array( $params['status_text'], $ItemStatus->get_name(), $status_clear_icon, $filter_classes[ $filter_class_i ] ), + $params['filter_mask'] ); + } + } + if( count( $task_status_titles ) > 0 ) + { + $task_status_titles_string = $task_status_prefix.implode( $task_status_separator, $task_status_titles ); + $title_array['task_statuses'] = str_replace( array( '$group_title$', '$filter_items$' ), + ( count( $task_status_titles ) > 1 ? + array( $params['statuses_text'], $params['before_items'].$task_status_titles_string.$params['after_items'] ) : + array( $params['status_text'], $task_status_titles_string ) ), $params['group_mask'] ); + $filter_class_i++; } - $filter_class_i++; } } @@ -1597,6 +1727,36 @@ function get_filter_titles( $ignore = array(), $params = array() ) } } + + // RENDERERS: + if( $params['display_renderer'] && + ! empty( $this->filters['renderers'] ) ) + { + global $Plugins; + $filter_class_i = ( $filter_class_i > count( $filter_classes ) - 1 ) ? 0 : $filter_class_i; + $task_renderer_titles = array(); + foreach( $this->filters['renderers'] as $renderer_plugin_code ) + { + if( $renderer_Plugin = & $Plugins->get_by_code( $renderer_plugin_code, false, false ) ) + { + $renderer_clear_icon = $clear_icon ? action_icon( T_('Remove this filter'), 'remove', regenerate_url( $this->param_prefix.'renderers='.$renderer_Plugin->code ) ) : ''; + $task_renderer_titles[] = str_replace( array( '$group_title$', '$filter_name$', '$clear_icon$', '$filter_class$' ), + array( $params['renderer_text'], $renderer_Plugin->name, $renderer_clear_icon, $filter_classes[ $filter_class_i ] ), + $params['filter_mask'] ); + } + } + if( count( $task_renderer_titles ) > 0 ) + { + $task_renderer_titles_string = implode( $params['separator_or'], $task_renderer_titles ); + $title_array['task_renderers'] = str_replace( array( '$group_title$', '$filter_items$' ), + ( count( $task_renderer_titles ) > 1 ? + array( $params['renderers_text'], $params['before_items'].$task_renderer_titles_string.$params['after_items'] ) : + array( $params['renderer_text'], $task_renderer_titles_string ) ), + $params['group_mask'] ); + $filter_class_i++; + } + } + return $title_array; } @@ -1967,8 +2127,11 @@ function page_links( $params = array() ) */ function display_list( $params ) { + global $Item, $cat; + $params = array_merge( array( 'template' => NULL, + 'highlight_current' => true, ), $params ); if( ! empty( $params['template'] ) ) @@ -2005,6 +2168,31 @@ function display_list( $params ) // ONLY SUPPORTING Plain list: (not grouped by category) for now // TODO: maybe support group by category. Use case??? + $item_template = $params['item_template']; + + if( ! empty( $params['highlight_current'] ) ) + { // Use template for active Item only when requested to highlight currently active Item: + $active_item_template = empty( $params['active_item_template'] ) ? $item_template : $params['active_item_template']; + if( $active_item_template == $item_template || + ! ( $active_item_Template = & $TemplateCache->get_by_code( $active_item_template, false, false ) ) ) + { // If active item template is not found in DB then use normal item template instead: + $active_item_template = $item_template; + } + // Highlight currently active Item ony when templates are different: + $highlight_current_item = ( $active_item_template != $item_template ); + } + else + { // Don't highlight currently active Item because it is not requested: + $highlight_current_item = false; + } + + $crossposted_item_template = empty( $params['crossposted_item_template'] ) ? $item_template : $params['crossposted_item_template']; + if( $crossposted_item_template == $item_template || + ! ( $crossposted_item_Template = & $TemplateCache->get_by_code( $crossposted_item_template, false, false ) ) ) + { // If crossposted item template is not found in DB then use normal item template instead: + $crossposted_item_template = $item_template; + } + $this->restart(); while( $row_Item = & $this->get_item() ) { @@ -2015,8 +2203,25 @@ function display_list( $params ) .( $params['active_item_slug'] == $row_Item->get( 'urltitle' ) ? '' : ' style="display:none"' ).'>'; } + if( $highlight_current_item && + ! empty( $Item ) && + $row_Item->ID == $Item->ID ) + { // Use different template for currently active Item: + $row_item_template = $active_item_template; + } + elseif( ! empty( $cat ) && + $row_Item->main_cat_ID != $cat && + in_array( $cat, $row_Item->get( 'extra_cat_IDs' ) ) ) + { // Use different template for crossposted Item: + $row_item_template = $crossposted_item_template; + } + else + { // Use normal template to not active Item: + $row_item_template = $item_template; + } + // Render Item by quick template: - echo render_template_code( $params['item_template'], $params, array( 'Item' => $row_Item ) ); + echo render_template_code( $row_item_template, $params, array( 'Item' => $row_Item ) ); if( ! empty( $params['switch_param_code'] ) ) { // End of switchable item block: @@ -2209,7 +2414,7 @@ function display_list_item_contents( & $disp_Item, $chapter_mode = false, & $ite $disp_param_prefix = $chapter_mode ? 'group_' : ''; // Is this the current item? - if( !empty($Item) && $disp_Item->ID == $Item->ID ) + if( ! empty( $params['highlight_current'] ) && ! empty( $Item ) && $disp_Item->ID == $Item->ID ) { // The current page is currently displaying the Item this link is pointing to // Let's display it as selected $link_class = $params['link_selected_class']; @@ -2246,7 +2451,7 @@ function display_list_item_contents( & $disp_Item, $chapter_mode = false, & $ite if( $params['disp_first_image'] == 'special' ) { // If we should display first picture before title then get "Cover" images and order them at top: $cover_image_params = array( - 'restrict_to_image_position' => 'cover,teaser,teaserperm,teaserlink,aftermore,inline', + 'restrict_to_image_position' => 'cover,background,teaser,teaserperm,teaserlink,aftermore,inline', // Sort the attachments to get firstly "Cover", then "Teaser", and "After more" as last order 'links_sql_select' => ', CASE ' .'WHEN link_position = "cover" THEN "1" ' diff --git a/inc/items/model/_itemquery.class.php b/inc/items/model/_itemquery.class.php index 82a1326f0ff..357328dabdb 100644 --- a/inc/items/model/_itemquery.class.php +++ b/inc/items/model/_itemquery.class.php @@ -33,6 +33,8 @@ class ItemQuery extends SQL var $author_login; var $assignees; var $assignees_login; + var $involved_user_IDs; + var $involved_user_logins; var $statuses; var $types; var $itemtype_usage; @@ -564,6 +566,67 @@ function where_author_assignee( $author_assignee ) } + /** + * Restrict items that have any comment OR internal/meta comment by the specific users + * + * @param string List of user IDs to restrict to (must have been previously validated) + */ + function where_involves( $involved_user_IDs ) + { + $this->involved_user_IDs = clear_ids_list( $involved_user_IDs ); + + if( empty( $this->involved_user_IDs ) ) + { + return; + } + + if( substr( $involved_user_IDs, 0, 1 ) == '-' ) + { // Exclude the users IF a list starts with MINUS sign: + $eq = 'NOT IN'; + } + else + { // Include the users: + $eq = 'IN'; + } + + $this->FROM_add( 'INNER JOIN T_comments AS involved_id ON involved_id.comment_item_ID = post_ID' ); + $this->WHERE_and( 'involved_id.comment_author_user_ID '.$eq.' ( '.$this->involved_user_IDs.' )' ); + } + + + /** + * Restrict items that have any comment OR internal/meta comment by the specific users + * + * @param string List of involved user logins to restrict to (must have been previously validated) + */ + function where_involves_logins( $involved_user_logins ) + { + $this->involved_user_logins = $involved_user_logins; + + if( empty( $this->involved_user_logins ) ) + { + return; + } + + if( substr( $involved_user_logins, 0, 1 ) == '-' ) + { // Exclude the users IF a list starts with MINUS sign: + $eq = 'NOT IN'; + $involved_user_IDs = get_users_IDs_by_logins( substr( $this->involved_user_logins, 1 ) ); + } + else + { // Include the users: + $eq = 'IN'; + $involved_user_IDs = get_users_IDs_by_logins( $this->involved_user_logins ); + } + + if( ! empty( $involved_user_IDs ) ) + { // Filter only if correct users are found by logins: + $this->FROM_add( 'INNER JOIN T_comments AS involved_login ON involved_login.comment_item_ID = post_ID' ); + $this->WHERE_and( 'involved_login.comment_author_user_ID '.$eq.' ( '.$involved_user_IDs.' )' ); + } + } + + /** * Restrict to specific locale * @@ -585,7 +648,7 @@ function where_locale( $locale ) /** * Restrict to specific (extended) statuses * - * @param string List of assignees to restrict to (must have been previously validated) + * @param string List of statuses to restrict to (must have been previously validated) */ function where_statuses( $statuses ) { @@ -618,6 +681,57 @@ function where_statuses( $statuses ) } + /** + * Restrict to specific (extended) statuses + * + * @param array Array of statuses to restrict to (must have been previously validated) + */ + function where_statuses_array( $statuses ) + { + if( ! is_array( $statuses ) ) + { // Wrong data: + return; + } + + $filter_without_status = false; + foreach( $statuses as $s => $status_ID ) + { + if( $status_ID == '-' ) + { // Filter by "No status": + $filter_without_status = true; + unset( $statuses[ $s ] ); + continue; + } + + $status_ID = intval( $status_ID ); + + if( empty( $status_ID ) ) + { // Remove a not number value from list: + unset( $statuses[ $s ] ); + continue; + } + + // Update value to integer format: + $statuses[ $s ] = $status_ID; + } + + $where_statuses = array(); + if( $filter_without_status ) + { // Filter by "No status": + $where_statuses[] = $this->dbprefix.'pst_ID IS NULL'; + } + if( ! empty( $statuses ) ) + { // Filter by specific statuses: + $where_statuses[] = $this->dbprefix.'pst_ID IN ( '.implode( ',', $statuses ).' )'; + } + + if( ! empty( $where_statuses ) ) + { // Apply filter by statuses: + $this->WHERE_and( implode( ' OR ', $where_statuses ) ); + } + } + + /** * Restrict to specific post types * @@ -1111,6 +1225,53 @@ function where_mustread( $mustread = false ) } + /** + * Restrict to specific renderer plugins + * + * @param array Renderer plugin codes + */ + function where_renderers( $renderers ) + { + global $DB, $Plugins; + + if( empty( $renderers ) ) + { // No filters: + return; + } + + foreach( $renderers as $r => $renderer ) + { // Escape chars: + $renderers[ $r ] = $DB->escape( $renderer ); + } + + $sql_conditions = array(); + + if( isset( $Plugins, $this->Blog ) ) + { // Get default renderer plugins for current Collection: + $default_renderers = $Plugins->validate_renderer_list( array( 'default' ), array( + 'setting_name' => 'coll_apply_rendering', + 'Blog' => $this->Blog, + ) ); + if( ! empty( $default_renderers ) ) + { + foreach( $renderers as $renderer ) + { + if( in_array( $renderer, $default_renderers ) ) + { // If at least one default renderer plugin is used to filter then get items which still use default renderers: + $sql_conditions[] = $this->dbprefix.'renderers = "default"'; + break; + } + } + } + } + + // Filter by selected renderers: + $sql_conditions[] = $this->dbprefix.'renderers REGEXP "(^|\.)('.implode( '|', $renderers ).')(\.|$)"'; + + $this->WHERE_and( implode( ' OR ', $sql_conditions ) ); + } + + /** * Generate order by clause * diff --git a/inc/items/model/_itemstatus.class.php b/inc/items/model/_itemstatus.class.php index 9c49e62e235..5cade976faa 100644 --- a/inc/items/model/_itemstatus.class.php +++ b/inc/items/model/_itemstatus.class.php @@ -24,6 +24,7 @@ class ItemStatus extends DataObject { var $name; + var $order; /** * Constructor @@ -43,6 +44,7 @@ function __construct( $db_row = NULL ) { $this->ID = $db_row->pst_ID; $this->name = $db_row->pst_name; + $this->order = $db_row->pst_order; } } @@ -70,6 +72,10 @@ function load_from_Request() // Name param_string_not_empty( 'pst_name', T_('Please enter a name.') ); $this->set_from_Request( 'name' ); + + // Order + param( 'pst_order', 'integer', true ); + $this->set_from_Request( 'order' ); return ! param_errors_detected(); } diff --git a/inc/items/model/_itemtype.class.php b/inc/items/model/_itemtype.class.php index bb6fe14daa6..bf5bfaae445 100644 --- a/inc/items/model/_itemtype.class.php +++ b/inc/items/model/_itemtype.class.php @@ -76,6 +76,7 @@ class ItemType extends DataObject var $front_order_excerpt = NULL; var $front_order_url = NULL; var $front_order_location = NULL; + var $front_order_workflow = 50; /** * Custom fields @@ -159,6 +160,7 @@ function __construct( $db_row = NULL ) $this->front_order_short_title = isset( $db_row->ityp_front_order_short_title ) ? $db_row->ityp_front_order_short_title : NULL; $this->front_order_instruction = isset( $db_row->ityp_front_order_instruction ) ? $db_row->ityp_front_order_instruction : NULL; $this->front_order_attachments = isset( $db_row->ityp_front_order_attachments ) ? $db_row->ityp_front_order_attachments : NULL; + $this->front_order_workflow = isset( $db_row->ityp_front_order_workflow ) ? $db_row->ityp_front_order_workflow : NULL; $this->front_order_text = isset( $db_row->ityp_front_order_text ) ? $db_row->ityp_front_order_text : NULL; $this->front_order_tags = isset( $db_row->ityp_front_order_tags ) ? $db_row->ityp_front_order_tags : NULL; $this->front_order_excerpt = isset( $db_row->ityp_front_order_excerpt ) ? $db_row->ityp_front_order_excerpt : NULL; @@ -336,6 +338,10 @@ function load_from_Request() param( 'ityp_front_order_attachments', 'integer', NULL ); $this->set_from_Request( 'front_order_attachments' ); + // Front-Office Order (Workflow) + param( 'ityp_front_order_workflow', 'integer', NULL ); + $this->set_from_Request( 'front_order_workflow' ); + // Use excerpt param( 'ityp_use_excerpt', 'string' ); $this->set_from_Request( 'use_excerpt' ); diff --git a/inc/items/views/_file_create_posts.form.php b/inc/items/views/_file_create_posts.form.php index 12927940b3a..a5cac2d2511 100644 --- a/inc/items/views/_file_create_posts.form.php +++ b/inc/items/views/_file_create_posts.form.php @@ -110,7 +110,7 @@ function fcpf_categories_select( $parent_category_ID = -1, $level = 0 ) $FileCache = & get_FileCache(); // Check if current user can add new categories -$user_has_cat_perms = $current_User->check_perm( 'blog_cats', '', false, $blog ); +$user_has_cat_perms = check_user_perm( 'blog_cats', '', false, $blog ); // Get the categories $categories = fcpf_categories_select(); diff --git a/inc/items/views/_item_edit_type.form.php b/inc/items/views/_item_edit_type.form.php index 966cbdc4894..abc465ce6b3 100644 --- a/inc/items/views/_item_edit_type.form.php +++ b/inc/items/views/_item_edit_type.form.php @@ -25,7 +25,7 @@ $item_type_perm_levels = array( 'standard', 'restricted', 'admin' ); foreach( $item_type_perm_levels as $i => $item_type_perm_level ) { - if( ! $current_User->check_perm( 'blog_item_type_'.$item_type_perm_level, 'edit', false, $Blog->ID ) ) + if( ! check_user_perm( 'blog_item_type_'.$item_type_perm_level, 'edit', false, $Blog->ID ) ) { unset( $item_type_perm_levels[ $i ] ); } @@ -90,7 +90,7 @@ function get_name_for_itemtype( $ityp_ID, $name ) 'td_class' => 'center %conditional( "'.$edited_Item->ityp_ID.'" == #ityp_ID#, " info", "" )%' ); -if( $current_User->check_perm( 'options', 'edit' ) ) +if( check_user_perm( 'options', 'edit' ) ) { // Add aactions if current user has a permission: $Results->cols[] = array( 'th' => TB_('Actions'), diff --git a/inc/items/views/_item_expert.form.php b/inc/items/views/_item_expert.form.php index 39871fecd7b..cbe077035d3 100644 --- a/inc/items/views/_item_expert.form.php +++ b/inc/items/views/_item_expert.form.php @@ -13,10 +13,6 @@ */ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); -/** - * @var User - */ -global $current_User; /** * @var Item */ @@ -47,6 +43,7 @@ global $bozo_start_modified, $creating; global $item_title, $item_content; global $redirect_to, $orig_action; +global $attachment_tab; // Determine if we are creating or updating... $creating = is_create_action( $action ); @@ -109,7 +106,7 @@ ?>
    -
    +
    check_perm( 'options', 'edit' ) ) + if( check_user_perm( 'options', 'edit' ) ) { // Add an icon to edit item type if current user has a permission: $item_type_edit_link = ' '.action_icon( TB_('Edit this Post Type...'), 'edit', $admin_url.'?ctrl=itemtypes&action=edit&ityp_ID='.$edited_Item->get( 'ityp_ID' ) ); } @@ -153,8 +150,18 @@ { $item_type_edit_link = ''; } + if( $ItemType->is_enabled( $edited_Item->get_blog_ID() ) ) + { // If Item Type is enabled for the Item's Collection: + $item_type_before = ''; + $item_type_after = ''; + } + else + { // Mark with orange label if Item Type is disabled for the Item's Collection: + $item_type_before = ''; + $item_type_after = ''; + } $Form->begin_fieldset( $form_title_item_ID.get_manual_link( 'post-contents-panel' ) - .''.sprintf( TB_('Type: %s'), $item_type_link ).$item_type_edit_link.'', + .''.$item_type_before.TB_('Type').$item_type_after.': '.$item_type_link.$item_type_edit_link.'', array( 'id' => 'itemform_content' ) ); $Form->switch_layout( 'fields_table' ); @@ -190,10 +197,46 @@ $Form->hidden( 'post_title', $item_title ); } $Form->end_fieldset(); + + // URL slugs: + //add slug_changed field - needed for slug trim, if this field = 0 slug will trimmed + $Form->hidden( 'slug_changed', 0 ); + $edit_slug_link = ''; + if( $edited_Item->ID > 0 && check_user_perm( 'slugs', 'view' ) ) + { // Current User has a permission to view slugs: + // Get icon to copy canonical slug to clipboard: + $edit_slug_link = action_icon( TB_('Copy slug to clipboard'), 'clipboard-copy', '#', TB_('Copy slug'), 3, 4, array( + 'id' => 'item_canonical_slug_clipboard_icon', // ID is used to highlight on coping process + 'onclick' => 'return evo_copy_to_clipboard( \'item_canonical_slug_clipboard_icon\', \''.format_to_js( $edited_Item->get( 'urltitle' ) ).'\' )', + ) ).' '; + // Get link to edit slugs page: + $edit_slug_link .= action_icon( TB_('Edit slugs'), 'edit', $admin_url.'?ctrl=slugs&slug_item_ID='.$edited_Item->ID, TB_('Edit slugs'), 3, 4 ) + // TRANS: Full phrase is "Edit slugs for this post" + .' '.TB_('for this post').' - '; + } + + if( empty( $edited_Item->tiny_slug_ID ) ) + { // No tiny URL: + $tiny_slug_info = TB_('No Tiny URL yet.'); + } + else + { // Get a link to tiny URL: + $tiny_slug_info = $edited_Item->get_tinyurl_link( array( + 'before' => TB_('Tiny URL').': ', + 'after' => '' + ) ).' '; + // Get icon to copy tiny URL to clipboard: + $tiny_slug_info .= action_icon( TB_('Copy Tiny URL to clipboard'), 'clipboard-copy', '#', '', NULL, NULL, array( + 'id' => 'item_tiny_url_clipboard_icon', // ID is used to highlight on coping process + 'onclick' => 'return evo_copy_to_clipboard( \'item_tiny_url_clipboard_icon\', \''.$edited_Item->get_tinyurl().'\' )', + ) ); + } + $Form->text_input( 'post_urltitle', $edited_Item->get_slugs(), 40, TB_('URL slugs'), $edit_slug_link.$tiny_slug_info, array( 'maxlength' => 210 ) ); + $Form->switch_layout( NULL ); if( $edited_Item->get_type_setting( 'allow_attachments' ) && - $current_User->check_perm( 'files', 'view', false ) ) + check_user_perm( 'files', 'view', false ) ) { // If current user has a permission to view the files AND attachments are allowed for the item type: load_class( 'links/model/_linkitem.class.php', 'LinkItem' ); // Initialize this object as global because this is used in many link functions: @@ -273,7 +316,7 @@ echo ''; } if( $edited_Item->get_type_setting( 'usage' ) == 'widget-page' && - $current_User->check_perm( 'blog_properties', 'edit', false, $Blog->ID ) ) + check_user_perm( 'blog_properties', 'edit', false, $Blog->ID ) ) { // Display a button to edit widgets only if item type is used for page containers and current user has permission to edit widgets: echo ''.TB_('Edit widgets now').''; } @@ -289,17 +332,74 @@ $Form->end_fieldset(); + global $UserSettings; + + $active_tab_pane_value = $UserSettings->get_collection_setting( 'active_tab_pane_itemform', $Blog->ID ); + + echo ''; - // ####################### ATTACHMENTS/LINKS ######################### - $fold_images_attachments_block = ( $orig_action != 'update_edit' && $orig_action != 'create_edit' ); // don't fold the links block on these two actions - $Form->attachments_fieldset( $edited_Item, $fold_images_attachments_block ); + echo ''; + + echo '
    '; + + $attachment_tab = true; + $fold_images_attachments_block = ( $orig_action != 'update_edit' && $orig_action != 'create_edit' ); // don't fold the links block on these two actions + $Form->attachments_fieldset( $edited_Item, $fold_images_attachments_block ); + if( count( $custom_fields ) ) { // Display fieldset with custom fields only if at least one exists: - $custom_fields_title = TB_('Custom fields').get_manual_link( 'post-custom-fields-panel' ); + $custom_fields_title = get_manual_link( 'post-custom-fields-panel' ); if( $current_User->check_perm( 'options', 'edit' ) ) { // Display an icon to edit post type if current user has a permission: $custom_fields_title .= '' @@ -309,55 +409,30 @@ .''; } - $Form->begin_fieldset( $custom_fields_title, array( 'id' => 'itemform_custom_fields', 'fold' => true ) ); + $Form->open_tab_pane( array( 'id' => 'custom_fields', 'class' => 'tab_pane_pads', 'right_items' => $custom_fields_title ) ); $Form->switch_layout( 'fields_table' ); - $Form->begin_fieldset(); // Display inputs to edit custom fields: display_editable_custom_fields( $Form, $edited_Item ); - $Form->end_fieldset(); $Form->switch_layout( NULL ); - $Form->end_fieldset(); + $Form->close_tab_pane(); } + + // ############################ ADVANCED PROPERTIES ############################# - $Form->begin_fieldset( TB_('Advanced properties').get_manual_link( 'post-advanced-properties-panel' ), array( 'id' => 'itemform_adv_props', 'fold' => true ) ); + $Form->open_tab_pane( array( 'id' => 'advance_properties', 'class' => 'tab_pane_pads', 'right_items' => get_manual_link( 'post-advanced-properties-panel' ) ) ); $Form->switch_layout( 'fields_table' ); - $Form->begin_fieldset(); - - // URL slugs: - //add slug_changed field - needed for slug trim, if this field = 0 slug will trimmed - $Form->hidden( 'slug_changed', 0 ); - $edit_slug_link = ''; - if( $edited_Item->ID > 0 && $current_User->check_perm( 'slugs', 'view' ) ) - { // user has permission to view slugs: - $edit_slug_link = action_icon( TB_('Edit slugs'), 'edit', $admin_url.'?ctrl=slugs&slug_item_ID='.$edited_Item->ID, TB_('Edit slugs'), 3, 4 ) - // TRANS: Full phrase is "Edit slugs for this post" - .' '.TB_('for this post').' - '; - } - - if( empty( $edited_Item->tiny_slug_ID ) ) - { - $tiny_slug_info = TB_('No Tiny URL yet.'); - } - else - { - $tiny_slug_info = $edited_Item->get_tinyurl_link( array( - 'before' => TB_('Tiny URL').': ', - 'after' => '' - ) ); - } - $Form->text_input( 'post_urltitle', $edited_Item->get_slugs(), 40, TB_('URL slugs'), $edit_slug_link.$tiny_slug_info, array( 'maxlength' => 210 ) ); if( $edited_Item->get_type_setting( 'use_tags' ) != 'never' ) { // Display tags: $link_to_tags_manager = ''; - if( $current_User->check_perm( 'options', 'view' ) ) + if( check_user_perm( 'options', 'view' ) ) { // Display a link to manage tags only when current use has the rights $link_to_tags_manager = ' – '.TB_('Go to tags manager').''; } @@ -485,17 +560,15 @@ } } - $Form->end_fieldset(); $Form->switch_layout( NULL ); - $Form->end_fieldset(); - + $Form->close_tab_pane(); // ####################### ADDITIONAL ACTIONS ######################### if( isset( $Blog ) && $Blog->get('allowtrackbacks') ) { - $Form->begin_fieldset( TB_('Additional actions').get_manual_link( 'post-edit-additional-actions-panel' ), array( 'id' => 'itemform_additional_actions', 'fold' => true ) ); + $Form->open_tab_pane( array( 'id' => 'allowtrackbacks', 'class' => 'tab_pane_pads', 'right_items' => get_manual_link( 'post-edit-additional-actions-panel' ) ) ); // --------------------------- TRACKBACK -------------------------------------- ?> @@ -506,25 +579,17 @@
    end_fieldset(); + $Form->close_tab_pane(); } - - // ####################### PLUGIN FIELDSETS ######################### - - $Plugins->trigger_event( 'AdminDisplayItemFormFieldset', array( 'Form' => & $Form, 'Item' => & $edited_Item, 'edit_layout' => 'expert' ) ); - - if( $current_User->check_perm( 'meta_comment', 'view', false, $Blog->ID ) ) + if( $edited_Item->can_see_meta_comments() ) { // ####################### INTERNAL COMMENTS ######################### $currentpage = param( 'currentpage', 'integer', 1 ); - $total_comments_number = generic_ctp_number( $edited_Item->ID, 'metas', 'total' ); param( 'comments_number', 'integer', $total_comments_number ); param( 'comment_type', 'string', 'meta' ); - $Form->begin_fieldset( TB_('Internal comments').get_manual_link( 'meta-comments-panel' ) - .( $total_comments_number > 0 ? ' '.$total_comments_number.'' : '' ), - array( 'id' => 'itemform_meta_cmnt', 'fold' => true, 'deny_fold' => ( $total_comments_number > 0 ) ) ); + $Form->open_tab_pane( array( 'id' => 'internal_comments', 'class' => 'tab_pane_pads', 'right_items' => get_manual_link( 'meta-comments-panel' ) ) ); if( $creating ) { // Display button to save new creating item: @@ -569,8 +634,38 @@ load_funcs( 'comments/model/_comment_js.funcs.php' ); } - $Form->end_fieldset(); + $Form->close_tab_pane(); + } + + // ####################### CHECKLIST ######################### + if( $edited_Item->can_see_meta_comments() && // Current User must has at least a permission to view meta comments + ( ! $creating || $edited_Item->can_meta_comment() ) ) // No need to display this tab for new Item if current User cannot add checklist item + { // Checklist is allowed only for users who can see meta/internal comments: + $Form->open_tab_pane( array( 'id' => 'checklist', 'class' => 'tab_pane_pads', 'right_items' => get_manual_link( 'item-checklist-panel' ) ) ); + if( $creating ) + { // Display button to save new creating item: + $Form->submit( array( 'actionArray[create_edit]', /* TRANS: This is the value of an input submit button */ TB_('Save post to start adding Checklist lines'), 'btn-primary' ) ); + } + else + { + // Make sure the widget does not insert a form here! + skin_widget( array( + // CODE for the widget: + 'widget' => 'item_checklist_lines', + // Optional display params + 'Item' => $edited_Item, + 'title' => NULL, + ) ); + } + $Form->close_tab_pane(); } + + echo '

    '; + + // ####################### PLUGIN FIELDSETS ######################### + + $Plugins->trigger_event( 'AdminDisplayItemFormFieldset', array( 'Form' => & $Form, 'Item' => & $edited_Item, 'edit_layout' => 'expert' ) ); + ?>
    @@ -634,29 +729,11 @@ if( $edited_Item->get_type_setting( 'use_parent' ) != 'never' ) { // Display parent ID: - $parent_info = ''; - if( $parent_Item = & $edited_Item->get_parent_Item() ) - { // Get parent item info if it is defined: - $status_icons = get_visibility_statuses( 'icons' ); - if( isset( $status_icons[ $parent_Item->get( 'status' ) ] ) ) - { // Status colored icon: - $parent_info .= $status_icons[ $parent_Item->get( 'status' ) ]; - } - // Title with link to permament url: - $parent_info .= ' '.$parent_Item->get_title( array( 'link_type' => 'permalink' ) ); - // Icon to edit: - $parent_info .= ' '.$parent_Item->get_edit_link( array( 'text' => '#icon#' ) ); - } - $parent_info .= ''; - - // Icon to select parent: - $parent_info .= action_icon( TB_('Select parent'), 'magnifier', '#', NULL, NULL, NULL, array( - 'onclick' => 'return evo_select_parent_load_window( '.$edited_Item->ID.', \''.$edited_Item->get_blog()->get( 'urlname' ).'\' )' ) ); - echo ''.TB_('Parent ID').':'; - $Form->text_input( 'post_parent_ID', $edited_Item->get( 'parent_ID' ), 11, '', $parent_info, array( - 'required' => ( $edited_Item->get_type_setting( 'use_parent' ) == 'required' ), - 'style' => 'width:115px', + $Form->item_selector( 'post_parent_ID', $edited_Item->get( 'parent_ID' ), '', array( + 'window_title_page1' => NT_('Select the parent'), + 'window_title_page2' => NT_('Select this Post as parent:'), + 'required' => ( $edited_Item->get_type_setting( 'use_parent' ) == 'required' ), ) ); echo ''; } @@ -665,7 +742,7 @@ $Form->hidden( 'post_parent_ID', $edited_Item->get( 'parent_ID' ) ); } - if( $current_User->check_perm( 'users', 'edit' ) ) + if( check_user_perm( 'users', 'edit' ) ) { // If current User has full access to edit other users, // Display item's owner: echo ''.TB_('Owner').':'; @@ -689,7 +766,7 @@ echo ''; - if( $current_User->check_perm( 'blog_edit_ts', 'edit', false, $Blog->ID ) ) + if( check_user_perm( 'blog_edit_ts', 'edit', false, $Blog->ID ) ) { // If user has a permission to edit advanced properties of items: if( $edited_Item->get_type_setting( 'allow_featured' ) ) { // Display featured @@ -712,7 +789,7 @@ } // Single/page view: - if( $current_User->check_perm( 'blog_edit_ts', 'edit', false, $Blog->ID ) ) + if( check_user_perm( 'blog_edit_ts', 'edit', false, $Blog->ID ) ) { // If user has a permission to edit advanced properties of items: if( ! in_array( $edited_Item->get_type_setting( 'usage' ), array( 'intro-front', 'intro-main', 'intro-cat', 'intro-tag', 'intro-sub', 'intro-all', 'content-block', 'special' ) ) ) { // We don't need this setting for intro, content block and special items: @@ -727,7 +804,7 @@ } // Issue date: - if( $current_User->check_perm( 'blog_edit_ts', 'edit', false, $Blog->ID ) ) + if( check_user_perm( 'blog_edit_ts', 'edit', false, $Blog->ID ) ) { // If user has a permission to edit advanced properties of items: echo '
    '; $Form->output = false; @@ -849,7 +926,7 @@ $Form->switch_layout( NULL ); } - if( $current_User->check_perm( 'blog_edit_ts', 'edit', false, $Blog->ID ) ) + if( check_user_perm( 'blog_edit_ts', 'edit', false, $Blog->ID ) ) { // If user has a permission to edit advanced properties of items: if( $edited_Item->get_type_setting( 'use_comment_expiration' ) != 'never' ) { // Display comment expiration @@ -875,7 +952,7 @@ // ################### USER TAGGING ################### $Form->begin_fieldset( TB_('User Tagging').get_manual_link( 'post-user-tagging-panel' ) - .( $current_User->check_perm( 'options', 'view' ) ? action_icon( TB_('User Tags'), 'edit', $admin_url.'?ctrl=usertags', TB_('User Tags'), 3, 4, array( 'class' => 'action_icon pull-right' ) ) : '' ), + .( check_user_perm( 'options', 'view' ) ? action_icon( TB_('User Tags'), 'edit', $admin_url.'?ctrl=usertags', TB_('User Tags'), 3, 4, array( 'class' => 'action_icon pull-right' ) ) : '' ), array( 'id' => 'itemform_usertags', 'fold' => true ) ); $Form->switch_layout( 'table' ); @@ -902,7 +979,7 @@ } if( $is_not_content_block && - $current_User->check_perm( 'blog_edit_ts', 'edit', false, $Blog->ID ) ) + check_user_perm( 'blog_edit_ts', 'edit', false, $Blog->ID ) ) { // Display goal tracking and notifications for item with type usage except of content block // and if user has a permission to edit advanced properties of items: @@ -1026,7 +1103,7 @@ $quick_setting_url = $admin_url.'?ctrl=items&prev_action='.$prev_action.( $item_ID > 0 ? '&p='.$item_ID : '' ) .'&blog='.$Blog->ID.'&'.url_crumb( 'item' ).'&action='; - if( $current_User->check_perm( 'blog_post!published', 'create', false, $Blog->ID ) ) + if( check_user_perm( 'blog_post!published', 'create', false, $Blog->ID ) ) { // Display a link to show/hide quick button to publish the post ONLY if current user has a permission: echo '

    '; if( $UserSettings->get_collection_setting( 'show_quick_publish', $Blog->ID ) ) @@ -1130,15 +1207,89 @@ echo_item_add_version_js(); // JS code for link to link new version: echo_item_link_version_js(); -// JS code for selecting parent item: -if( $edited_Item->get_type_setting( 'use_parent' ) != 'never' ) -{ - echo_item_select_parent_js(); +if( $edited_Item->can_meta_comment() ) +{ // Init Item Checklist JS to update red badge in tab of not checked lines: + expose_var_to_js( 'evo_item_checklist_config', true ); } // JS to post excerpt mode switching: ?> '; +expose_var_to_js( 'evo_init_item_list_clipboard_js', true ); if( $action == 'view' ) -{ // Load JS functions to work with comments +{ // Load JS functions to work with comments load_funcs( 'comments/model/_comment_js.funcs.php' ); // Handle show_comments radioboxes @@ -860,9 +860,14 @@ } elseif( $allow_items_list_form ) { // Allow to select item for action only on items list if current user can edit at least one item status: - echo ' '. - ' '. - ' '; + + // Buttons to check/uncheck/invert all Items: + $Form->checkbox_controls( 'selected_items', array( + 'before_buttons' => '', + 'after_buttons' => ' ', + 'button_class' => 'btn btn-default', + 'icon_class' => '', + ) ); echo T_('With checked posts').': '; @@ -870,9 +875,11 @@ echo_item_status_buttons( $Form, NULL, 'items_visibility' ); echo_status_dropdown_button_js( 'post' ); + echo ' '; $Form->button( array( 'button', 'mass_change_main_cat', T_('Change primary category') ) ); $Form->button( array( 'button', 'mass_add_extra_cat', T_('Add secondary category') ) ); - if( is_pro() && is_logged_in() && $current_User->check_perm( 'options', 'edit' ) ) + echo ' '; + if( is_pro() && check_user_perm( 'options', 'edit' ) ) { // Export Items only for PRO version: $Form->button( array( 'submit', 'actionArray[mass_export]', T_('Export to XML') ) ); } diff --git a/inc/items/views/_item_list_sidebar.view.php b/inc/items/views/_item_list_sidebar.view.php index 164f6605244..16e9c26cf36 100644 --- a/inc/items/views/_item_list_sidebar.view.php +++ b/inc/items/views/_item_list_sidebar.view.php @@ -35,8 +35,9 @@ global $tab; global ${$pp.'flagged'}, ${$pp.'mustread'}, ${$pp.'show_past'}, ${$pp.'show_future'}, ${$pp.'show_statuses'}, - ${$pp.'s'}, ${$pp.'sentence'}, ${$pp.'exact'}, ${$pp.'author'}, ${$pp.'author_login'}, ${$pp.'assgn'}, - ${$pp.'assgn_login'}, ${$pp.'status'}, ${$pp.'types'}; + ${$pp.'s'}, ${$pp.'sentence'}, ${$pp.'exact'}, ${$pp.'author'}, ${$pp.'author_login'}, + ${$pp.'assgn'}, ${$pp.'assgn_login'}, ${$pp.'involves'}, ${$pp.'involves_login'}, + ${$pp.'status'}, ${$pp.'statuses'}, ${$pp.'types'}, ${$pp.'renderers'}; $flagged = ${$pp.'flagged'}; $mustread = ${$pp.'mustread'}; @@ -50,8 +51,12 @@ $author_login = ${$pp.'author_login'}; $assgn = ${$pp.'assgn'}; $assgn_login = ${$pp.'assgn_login'}; +$involves = ${$pp.'involves'}; +$involves_login = ${$pp.'involves_login'}; $status = ${$pp.'status'}; +$statuses = ${$pp.'statuses'}; $types = ${$pp.'types'}; +$renderers = ${$pp.'renderers'}; load_funcs( 'skins/_skin.funcs.php' ); @@ -189,21 +194,35 @@ $ItemStatusCache->load_all(); // TODO: load for current blog only if( count( $ItemStatusCache->cache ) ) { // Display only if at least one status exists in DB: - $fold_status = ( $ItemList->default_filters['statuses'] == $ItemList->filters['statuses'] ); - $Form->begin_fieldset( T_('Status'), array( 'id' => 'items_filter_status', 'fold' =>true, 'default_fold' => empty( $status ) ) ); + $Form->begin_fieldset( T_('Status'), array( 'id' => 'items_filter_status', 'fold' =>true, 'default_fold' => empty( $status ) && empty( $statuses ) ) ); echo '

    '; + + // Buttons to check/uncheck/reverse all status filters: + $Form->checkbox_controls( $pp.'statuses' ); + $Form->end_fieldset(); } @@ -313,6 +332,40 @@ } $Form->end_fieldset(); +// INVOLVES: +// TODO: allow multiple selection +// Load only first 21 users to know when we should display an input box instead of full users list +$UserCache->load_blogmembers( $Blog->ID, 21 ); +$user_count = count( $UserCache->cache ); +$fold_involves = ( $ItemList->default_filters['involves'] == ( empty( $ItemList->filters['involves'] ) ? NULL : $ItemList->filters['involves'] ) ); +$Form->begin_fieldset( T_('Involves'), array( 'id' => 'items_filter_involves', 'fold' => true, 'default_fold' => $fold_involves ) ); +if( $user_count ) +{ + if( $user_count > 20 ) + { // Display an input box to enter user login: + echo ' '; + } + else + { // Display a list of users: + echo ''; + } +} +$Form->end_fieldset(); + // CATEGORIES: $fold_cat_array = ( $ItemList->default_filters['cat_array'] == $ItemList->filters['cat_array'] ); $fold_cat_single = ( $ItemList->default_filters['cat_single'] == $ItemList->filters['cat_single'] ); @@ -354,6 +407,32 @@ ) ); $Form->end_fieldset(); +// RENDERER PLUGINS: +global $Plugins; +$renderer_plugins = $Plugins->get_renderer_options( NULL, array( + 'setting_name' => 'coll_apply_rendering', + 'Blog' => $Blog, +) ); +if( count( $renderer_plugins ) ) +{ // Display only if at least one renderer plugin is allowed to be selected/unselected per Item of the current Collection: + $Form->begin_fieldset( T_('Uses Renderer'), array( 'id' => 'items_filter_renderer', 'fold' => true, 'default_fold' => empty( $renderers ) ) ); + echo ''; + + // Buttons to check/uncheck/reverse all renderer plugin filters: + $Form->checkbox_controls( $pp.'renderers' ); + + $Form->end_fieldset(); +} + $Form->end_form(); // Enable JS for fieldset folding: diff --git a/inc/items/views/_item_list_track.view.php b/inc/items/views/_item_list_track.view.php index ec6e82d9215..9ce050640ef 100644 --- a/inc/items/views/_item_list_track.view.php +++ b/inc/items/views/_item_list_track.view.php @@ -153,7 +153,7 @@ function deadline( $date ) ); -if( $current_User->check_perm( 'blog_post_statuses', 'edit', false, $Blog->ID ) ) +if( check_user_perm( 'blog_post_statuses', 'edit', false, $Blog->ID ) ) { // We have permission to add a post with at least one status: $ItemList->global_icon( T_('Create a new task...'), 'new', '?ctrl=items&action=new&blog='.$Blog->ID.'&redirect_to='.rawurlencode( regenerate_url( '', '', '', '&' ) ), T_('New task').' »', 3, 4, array( 'class' => 'action_icon btn-primary' ) ); } @@ -205,7 +205,7 @@ function deadline( $date ) 'ID_name' => 'post_ID', 'field_type' => $field_type, 'field_class' => 'autocomplete_login only_assignees', - 'null_text' => TS_('No user') ) ); + 'null_text' => T_('No user') ) ); // Print JS to edit a task status global $DB; @@ -239,8 +239,8 @@ function getApplicableStatus( el, selected ) { echo_editable_column_js( array( 'column_selector' => '.task_status_edit', 'ajax_url' => get_htsrv_url().'async.php?action=item_task_edit&field=status&'.url_crumb( 'itemtask' ), - 'options' => 'getApplicableStatus( jQuery( this ), result[1] );', + 'options_eval' => 'getApplicableStatus( jQuery( this ), result[1] );', 'new_field_name' => 'new_status', 'ID_value' => 'jQuery( this ).attr( "rel" )', 'ID_name' => 'post_ID' ) ); -?> \ No newline at end of file +?> diff --git a/inc/items/views/_item_mass.form.php b/inc/items/views/_item_mass.form.php index 782f5d0ef53..519a665c53c 100644 --- a/inc/items/views/_item_mass.form.php +++ b/inc/items/views/_item_mass.form.php @@ -16,10 +16,6 @@ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); -/** - * @var User - */ -global $current_User; /** * @var Item */ diff --git a/inc/items/views/_item_mass_edit.view.php b/inc/items/views/_item_mass_edit.view.php index bd03ee21265..bcff082cd07 100644 --- a/inc/items/views/_item_mass_edit.view.php +++ b/inc/items/views/_item_mass_edit.view.php @@ -24,9 +24,9 @@ */ global $ItemList; -global $redirect_to, $current_User, $admin_url; +global $redirect_to, $admin_url; -$perm_slugs_view = $current_User->check_perm( 'slugs', 'view' ); +$perm_slugs_view = check_user_perm( 'slugs', 'view' ); $Form = new Form(); diff --git a/inc/items/views/_item_propose.form.php b/inc/items/views/_item_propose.form.php index 4237d1e88f0..5cc76e99dbf 100644 --- a/inc/items/views/_item_propose.form.php +++ b/inc/items/views/_item_propose.form.php @@ -161,7 +161,7 @@ if( count( $custom_fields ) ) { // Display fieldset with custom fields only if at least one exists: $custom_fields_title = TB_('Custom fields').get_manual_link( 'post-custom-fields-panel' ); - if( $current_User->check_perm( 'options', 'edit' ) ) + if( check_user_perm( 'options', 'edit' ) ) { // Display an icon to edit post type if current user has a permission: $custom_fields_title .= '' .action_icon( TB_('Edit fields...'), 'edit', diff --git a/inc/items/views/_itemstatus.form.php b/inc/items/views/_itemstatus.form.php index 38464f39ac4..8d9050b0197 100644 --- a/inc/items/views/_itemstatus.form.php +++ b/inc/items/views/_itemstatus.form.php @@ -37,6 +37,7 @@ $Form->begin_fieldset( TB_('General') ); $Form->text_input( 'pst_name', $edited_ItemStatus->get( 'name' ), 30, TB_('Name'), '', array( 'required' => true ) ); + $Form->text_input( 'pst_order', $edited_ItemStatus->get( 'order' ), 30, TB_('Order'), '', array( 'type' => 'number' ) ); $Form->end_fieldset(); /** @@ -174,9 +175,7 @@ function item_status_type_checkbox( $row ) function get_name_for_itemtype( $id, $name ) { - global $current_User; - - if( $current_User->check_perm( 'options', 'edit' ) ) + if( check_user_perm( 'options', 'edit' ) ) { // Not reserved id AND current User has permission to edit the global settings $ret_name = ''.$name.''; } diff --git a/inc/items/views/_itemstatuses.view.php b/inc/items/views/_itemstatuses.view.php index 472c27a0315..5a6ac7fb803 100644 --- a/inc/items/views/_itemstatuses.view.php +++ b/inc/items/views/_itemstatuses.view.php @@ -16,6 +16,19 @@ global $admin_url; +function item_status_order( $item_status_order, $item_status_id ) +{ + if( check_user_perm( 'options', 'edit', true ) ) + { + return ''.( $item_status_order === NULL ? '-' : $item_status_order ).''; + } + else + { + return $item_status_order; + } + +} + // Create query $SQL = new SQL(); $SQL->SELECT( '*' ); @@ -42,7 +55,16 @@ 'td' => '$pst_name$', ); -if( $current_User->check_perm( 'options', 'edit', false ) ) +$Results->cols[] = array( + 'th' => T_('Order'), + 'th_class' => 'shrinkwrap hidden-xs', + 'order' => 'pst_order', + 'td_class' => 'right jeditable_cell item_status_order_edit hidden-xs', + 'td' => '%item_status_order( #pst_order#, #pst_ID# )%', + 'extra' => array( 'rel' => '#pst_ID#' ), + ); + +if( check_user_perm( 'options', 'edit', false ) ) { // We have permission to modify: $Results->cols[] = array( 'th' => T_('Actions'), @@ -60,4 +82,23 @@ // Display results: $Results->display(); -?> \ No newline at end of file +?> + + \ No newline at end of file diff --git a/inc/items/views/_itemtag.form.php b/inc/items/views/_itemtag.form.php index 62555038bfc..6dc7ecac4f2 100644 --- a/inc/items/views/_itemtag.form.php +++ b/inc/items/views/_itemtag.form.php @@ -96,7 +96,7 @@ function tagitem_edit_actions( $Item ) { - global $current_User, $edited_ItemTag; + global $edited_ItemTag; // Display the edit icon if current user has the rights: $r = $Item->get_edit_link( array( @@ -106,7 +106,7 @@ function tagitem_edit_actions( $Item ) 'title' => '#', 'class' => '' ) ); - if( $current_User->check_perm( 'item_post!CURSTATUS', 'edit', false, $Item ) ) + if( check_user_perm( 'item_post!CURSTATUS', 'edit', false, $Item ) ) { // Display the unlink icon if current user has the rights: $r .= action_icon( TB_('Unlink this tag from post!'), 'unlink', regenerate_url( 'tag_ID,action,tag_filter', 'tag_ID='.$edited_ItemTag->ID.'&item_ID='.$Item->ID.'&action=unlink&return_to='.urlencode( regenerate_url( 'action', '', '', '&' ) ).'&'.url_crumb( 'tag' ) ), diff --git a/inc/items/views/_itemtags.view.php b/inc/items/views/_itemtags.view.php index f0aedf026d5..8facb2f44da 100644 --- a/inc/items/views/_itemtags.view.php +++ b/inc/items/views/_itemtags.view.php @@ -14,7 +14,7 @@ */ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); -global $current_User, $admin_url; +global $admin_url; $SQL = new SQL(); $SQL->SELECT( 'tag_ID, tag_name, COUNT( it.itag_itm_ID ) AS tag_count' ); @@ -84,9 +84,9 @@ function filter_tags( & $Form ) function tag_td_name( $tag_ID, $tag_name ) { - global $current_User, $admin_url; + global $admin_url; - if( $current_User->check_perm( 'options', 'edit' ) ) + if( check_user_perm( 'options', 'edit' ) ) { // Display tag name as link to edit form only if current user has a perm: $tag_name = '' @@ -111,7 +111,7 @@ function tag_td_name( $tag_ID, $tag_name ) ); -if( $current_User->check_perm( 'options', 'edit' ) ) +if( check_user_perm( 'options', 'edit' ) ) { function tag_td_actions( $tag_ID ) { @@ -126,7 +126,7 @@ function tag_td_actions( $tag_ID ) 'td' => '%tag_td_actions( #tag_ID# )%', ); - if( $current_User->check_perm( 'options', 'edit' ) ) + if( check_user_perm( 'options', 'edit' ) ) { // Allow to clean up tags only if current user has a permission to edit tags: $Results->global_icon( T_('Cleanup orphans'), 'cleanup', regenerate_url( 'action', 'action=cleanup&return_to='.urlencode( regenerate_url( 'action', '', '', '&' ) ) ).'&'.url_crumb( 'tag' ), T_('Cleanup orphans'), 3, 4 ); } @@ -135,4 +135,4 @@ function tag_td_actions( $tag_ID ) $Results->display(); -?> \ No newline at end of file +?> diff --git a/inc/items/views/_itemtype.form.php b/inc/items/views/_itemtype.form.php index f44c2750510..d8013f8ec03 100644 --- a/inc/items/views/_itemtype.form.php +++ b/inc/items/views/_itemtype.form.php @@ -16,7 +16,7 @@ load_class( '_core/ui/_table.class.php', 'Table' ); load_class( 'items/model/_itemtype.class.php', 'ItemType' ); -global $edited_Itemtype, $thumbnail_sizes, $admin_url, $Blog, $current_User; +global $edited_Itemtype, $thumbnail_sizes, $admin_url, $Blog; // Determine if we are creating or updating... global $action; @@ -69,7 +69,7 @@ $TemplateCache = & get_TemplateCache(); $TemplateCache->load_by_context( $context ); $template_options = array( NULL => sprintf( TB_('Use PHP %s'), '(_item_content.inc.php)' ) ) + $TemplateCache->get_code_option_array(); - $template_input_suffix = ( $current_User->check_perm( 'options', 'edit' ) ? ' ' + $template_input_suffix = ( check_user_perm( 'options', 'edit' ) ? ' ' .action_icon( '', 'edit', $admin_url.'?ctrl=templates&context='.$context.'&blog='.$Blog->ID, NULL, NULL, NULL, array( 'onclick' => 'return b2template_list_highlight( this )' ), array( 'title' => TB_('Manage templates').'...' ) ) : '' ); $Form->select_input_array( 'ityp_template_excerpt', $edited_Itemtype->get( 'template_excerpt' ), $template_options, TB_('Template for Excerpt display'), NULL, array( 'input_suffix' => $template_input_suffix ) ); $Form->select_input_array( 'ityp_template_normal', $edited_Itemtype->get( 'template_normal' ), $template_options, TB_('Template for Teaser display'), NULL, array( 'input_suffix' => $template_input_suffix ) ); @@ -162,8 +162,13 @@ $Form->checkbox( 'ityp_allow_switchable', $edited_Itemtype->allow_switchable, TB_('Allow switchable'), TB_('Check to allow dynamically switchable blocks inside the content'), '', 1 ); $Form->end_fieldset(); -$Form->begin_fieldset( TB_('Use of Location').get_manual_link( 'item-type-location' ), array( 'id' => 'itemtype_location' ) ); - $Form->begin_line( TB_('Use country') ); +$Form->begin_fieldset( T_('Workflow Properties').get_manual_link( 'workflow' ), array( 'id' => 'itemtype_features' ) ); + $Form->text_input( 'ityp_front_order_workflow', $edited_Itemtype->front_order_workflow, 6,T_('Front-Office Order'), T_('Leave empty to hide'), $front_order_params ); +$Form->end_fieldset(); + +$Form->begin_fieldset( T_('Use of Location').get_manual_link( 'item-type-location' ), array( 'id' => 'itemtype_location' ) ); + $Form->begin_line( T_('Use country') ); + $Form->radio( 'ityp_use_country', $edited_Itemtype->use_country, $options ); $Form->text_input( 'ityp_front_order_location', $edited_Itemtype->front_order_location, 6, '   '.TB_('Front-Office Order').':', TB_('Leave empty to hide'), $front_order_params ); $Form->end_line(); @@ -517,15 +522,17 @@ function custom_field_edit_form_template( $new_templates, $limit_field_types, & $SQL = new SQL(); if( $current_ityp_ID ) { - $SQL->SELECT( 'pst_ID, pst_name, its_ityp_ID' ); + $SQL->SELECT( 'pst_ID, pst_order, pst_name, its_ityp_ID' ); $SQL->FROM( 'T_items__status' ); $SQL->FROM_add( 'JOIN T_items__type' ); $SQL->FROM_add( 'LEFT JOIN T_items__status_type ON its_ityp_ID = ityp_ID AND its_pst_ID = pst_ID' ); + $SQL->ORDER_BY( 'pst_order' ); $SQL->WHERE( 'ityp_ID = '.$current_ityp_ID ); } else { - $SQL->SELECT( 'pst_ID, pst_name, NULL AS its_ityp_ID' ); + $SQL->SELECT( 'pst_ID, pst_order, pst_name, NULL AS its_ityp_ID' ); + $SQL->ORDER_BY( 'pst_order' ); $SQL->FROM( 'T_items__status' ); } @@ -563,9 +570,7 @@ function item_status_type_checkbox( $row ) function get_name_for_itemstatus( $id, $name ) { - global $current_User; - - if( $current_User->check_perm( 'options', 'edit' ) ) + if( check_user_perm( 'options', 'edit' ) ) { // Not reserved id AND current User has permission to edit the global settings $ret_name = ''.$name.''; } @@ -582,6 +587,11 @@ function get_name_for_itemstatus( $id, $name ) 'td' => '%get_name_for_itemstatus( #pst_ID#, #pst_name# )%' ); +$Results->cols[] = array( + 'th' => TB_('Order'), + 'td' => '$pst_order$', + ); + $display_params = array( 'page_url' => $admin_url.'?ctrl=itemtypes&ityp_ID='.$current_ityp_ID.'&action=edit' ); diff --git a/inc/items/views/_itemtype_fields.form.php b/inc/items/views/_itemtype_fields.form.php index 8c8239dbb5b..9802416a594 100644 --- a/inc/items/views/_itemtype_fields.form.php +++ b/inc/items/views/_itemtype_fields.form.php @@ -57,9 +57,11 @@ $Form->checklist( $custom_field_options, '', TB_('Select fields'), false, false, array( 'input_prefix' => + ''. ' '. ' '. - '' + ''. + '' ) ); $Form->end_form( array( array( 'submit', 'actionArray[select_custom_fields]', TB_('Add fields now!'), 'SaveButton' ) ) ); diff --git a/inc/items/views/_itemtypes.view.php b/inc/items/views/_itemtypes.view.php index 28d4f5b4eb2..58dc3b9637e 100644 --- a/inc/items/views/_itemtypes.view.php +++ b/inc/items/views/_itemtypes.view.php @@ -37,7 +37,7 @@ */ function get_actions_for_itemtype( $id ) { - global $default_ids, $admin_url, $current_User; + global $default_ids, $admin_url; // Exit Item Type: $action = action_icon( T_('Edit this Item Type...'), 'edit', @@ -47,7 +47,7 @@ function get_actions_for_itemtype( $id ) $action .= action_icon( T_('Duplicate this Item Type...'), 'copy', regenerate_url( 'action', 'ityp_ID='.$id.'&action=new' ) ); - if( is_pro() && is_logged_in() && $current_User->check_perm( 'options', 'edit' ) ) + if( is_pro() && check_user_perm( 'options', 'edit' ) ) { // Export Item Type only for PRO version: $action .= action_icon( T_('Export this Item Type...'), 'download', $admin_url.'?ctrl=exportxml&action=export_itemtype&ityp_ID='.$id.'&'.url_crumb( 'itemtype' ) ); @@ -68,9 +68,7 @@ function get_actions_for_itemtype( $id ) */ function get_name_for_itemtype( $id, $name ) { - global $current_User; - - if( $current_User->check_perm( 'options', 'edit' ) ) + if( check_user_perm( 'options', 'edit' ) ) { // Not reserved id AND current User has permission to edit the global settings $ret_name = ''.$name.''; } @@ -93,9 +91,9 @@ function get_name_for_itemtype( $id, $name ) function ityp_row_enabled( $enabled, $item_type_ID ) { - global $current_User, $admin_url, $Collection, $Blog; + global $admin_url, $Collection, $Blog; - $perm_edit = $current_User->check_perm( 'options', 'edit', false ); + $perm_edit = check_user_perm( 'options', 'edit', false ); if( $enabled ) { // Enabled @@ -103,7 +101,7 @@ function ityp_row_enabled( $enabled, $item_type_ID ) { // URL to disable the item type $status_url = $admin_url.'?ctrl=itemtypes&action=disable&ityp_ID='.$item_type_ID.'&blog='.$Blog->ID.'&'.url_crumb( 'itemtype' ); } - $status_icon = get_icon( 'bullet_green', 'imgtag', array( 'title' => T_('The item type is enabled.') ) ); + $status_icon = get_icon( 'bullet_green', 'imgtag', array( 'title' => TB_('The item type is enabled.') ) ); } else { // Disabled @@ -111,7 +109,14 @@ function ityp_row_enabled( $enabled, $item_type_ID ) { // URL to enable the item type $status_url = $admin_url.'?ctrl=itemtypes&action=enable&ityp_ID='.$item_type_ID.'&blog='.$Blog->ID.'&'.url_crumb( 'itemtype' ); } - $status_icon = get_icon( 'bullet_empty_grey', 'imgtag', array( 'title' => T_('The item type is disabled.') ) ); + if( $Blog->has_items_per_item_type( $item_type_ID ) ) + { // Use orange icon if collection has at least one Item per this disabled Item Type: + $status_icon = get_icon( 'bullet_orange', 'imgtag', array( 'title' => TB_('Disabled but used by some Items in this collection.') ) ); + } + else + { // Use "grey empty" icon if collection has no Items per this disabled Item Type: + $status_icon = get_icon( 'bullet_empty_grey', 'imgtag', array( 'title' => TB_('The item type is disabled.') ) ); + } } if( isset( $status_url ) ) @@ -134,7 +139,7 @@ function ityp_row_enabled( $enabled, $item_type_ID ) function ityp_row_default( $item_type_ID ) { - global $current_User, $admin_url, $Collection, $Blog; + global $admin_url, $Collection, $Blog; if( $Blog->get_setting( 'default_post_type' ) == $item_type_ID ) { // The item type is default for current collection: @@ -142,7 +147,7 @@ function ityp_row_default( $item_type_ID ) } else { // The item type is not default: - if( $current_User->check_perm( 'blog_properties', 'edit', false, $Blog->ID ) ) + if( check_user_perm( 'blog_properties', 'edit', false, $Blog->ID ) ) { // URL to use the item type as default if current user has a permission to edit collection properties: $status_url = $admin_url.'?ctrl=itemtypes&action=default&ityp_ID='.$item_type_ID.'&blog='.$Blog->ID.'&'.url_crumb( 'itemtype' ); $status_icon_title = sprintf( T_('Set this item type as the default for %s.'), $Blog->get( 'shortname' ) ); @@ -242,7 +247,7 @@ function ityp_row_perm_level( $level, $id ) 'td_class' => 'center', ); -if( $current_User->check_perm( 'options', 'edit', false ) ) +if( check_user_perm( 'options', 'edit', false ) ) { // We have permission to modify: $Results->cols[] = array( 'th' => T_('Actions'), diff --git a/inc/links/links.ctrl.php b/inc/links/links.ctrl.php index 778e6893b6d..b909ec918b9 100644 --- a/inc/links/links.ctrl.php +++ b/inc/links/links.ctrl.php @@ -283,8 +283,6 @@ // require colorbox js require_js_helper( 'colorbox' ); -// Init JS to quick upload several files: -init_fileuploader_js( 'rsc_url', ( $action == 'edit_links' ) ); $AdminUI->disp_html_head(); $AdminUI->disp_body_top( false ); diff --git a/inc/links/model/_link.class.php b/inc/links/model/_link.class.php index 77df1c19ce7..03620736218 100644 --- a/inc/links/model/_link.class.php +++ b/inc/links/model/_link.class.php @@ -305,10 +305,15 @@ function get_download_url( $params = array() ) if( $LinkOwner->type == 'item' && $LinkOwner->Item ) { // Use specific url for Item to download + if( ! $LinkOwner->Item->get_coll_setting( 'download_enable' ) ) + { // If ?disp=download is disabled then use simple original URL to the File: + return $File->get_url(); + } + switch( $params['type'] ) { case 'action': - // Get URL to froce download a file + // Get URL to force download a file if( $File->get_ext() == 'zip' ) { // Provide direct url to ZIP files // NOTE: The same hardcoded place is in the file "htsrv/download.php", lines 56-60 @@ -339,8 +344,6 @@ function get_download_url( $params = array() ) */ function can_be_file_deleted() { - global $current_User; - if( ! is_logged_in() ) { // Not logged in user return false; @@ -354,7 +357,7 @@ function can_be_file_deleted() if( ! ( $File = & $this->get_File() ) || ! ( $FileRoot = & $File->get_FileRoot() ) || - ! $current_User->check_perm( 'files', 'edit_allowed', false, $FileRoot ) ) + ! check_user_perm( 'files', 'edit_allowed', false, $FileRoot ) ) { // Current user has no permission to edit this file return false; } diff --git a/inc/links/model/_link.funcs.php b/inc/links/model/_link.funcs.php index 8305c6803ff..cac8042802f 100644 --- a/inc/links/model/_link.funcs.php +++ b/inc/links/model/_link.funcs.php @@ -153,8 +153,7 @@ function get_link_owner_type( $link_ID ) */ function display_attachments_fieldset( & $Form, & $LinkOwner, $fold = false, $fieldset_prefix = '' ) { - global $admin_url, $inc_path; - global $current_User, $action; + global $admin_url, $inc_path, $action; if( ! isset( $GLOBALS[ 'files_Module' ] ) ) { // Files module is not enabled: @@ -213,13 +212,13 @@ function display_attachments_fieldset( & $Form, & $LinkOwner, $fold = false, $fi $fieldset_title .= ' '.get_manual_link( 'images-attachments-panel' ); } - if( is_logged_in() && $current_User->check_perm( 'admin', 'restricted' ) && $current_User->check_perm( 'files', 'view' ) ) + if( check_user_perm( 'admin', 'restricted' ) && check_user_perm( 'files', 'view' ) ) { // Check if current user has a permission to back-office files manager: $attach_files_url = $admin_url.'?ctrl=files&fm_mode=link_object&link_type='.( $LinkOwner->is_temp() ? 'temporary' : $LinkOwner->type ).( $LinkOwner->type != 'message' ? '&link_object_ID='.$LinkOwner->get_ID() : '' ); if( $linkowner_FileList = $LinkOwner->get_attachment_FileList( 1 ) ) { // Get first file of the Link Owner: $linkowner_File = & $linkowner_FileList->get_next(); - if( ! empty( $linkowner_File ) && $current_User->check_perm( 'files', 'view', false, $linkowner_File->get_FileRoot() ) ) + if( ! empty( $linkowner_File ) && check_user_perm( 'files', 'view', false, $linkowner_File->get_FileRoot() ) ) { // Obtain and use file root of first file: $linkowner_FileRoot = & $linkowner_File->get_FileRoot(); $attach_files_url .= '&root='.$linkowner_FileRoot->ID; @@ -243,7 +242,7 @@ function display_attachments_fieldset( & $Form, & $LinkOwner, $fold = false, $fi .action_icon( T_('Refresh'), 'refresh', $LinkOwner->get_edit_url(), T_('Refresh'), 3, 4, array( 'class' => 'action_icon btn btn-default btn-sm', 'onclick' => 'return evo_link_refresh_list( \''.( $LinkOwner->is_temp() ? 'temporary' : $LinkOwner->type ).'\', \''.$LinkOwner->get_ID().'\', \'refresh\', \''.$fieldset_prefix.'\' )' ) ) - .action_icon( T_('Sort'), 'ascending', ( is_admin_page() || ( is_logged_in() && $current_User->check_perm( 'admin', 'restricted' ) ) ) + .action_icon( T_('Sort'), 'ascending', ( is_admin_page() || check_user_perm( 'admin', 'restricted' ) ) ? $admin_url.'?ctrl=links&action=sort_links&link_type='.$LinkOwner->type.'&link_object_ID='.$LinkOwner->get_ID().'&'.url_crumb( 'link' ) : $LinkOwner->get_edit_url().'#', T_('Sort'), 3, 4, array( 'class' => 'action_icon btn btn-default btn-sm', 'onclick' => 'return evo_link_refresh_list( \''.( $LinkOwner->is_temp() ? 'temporary' : $LinkOwner->type ).'\', \''.$LinkOwner->get_ID().'\', \'sort\', \''.$fieldset_prefix.'\' )' ) ) @@ -257,7 +256,8 @@ function display_attachments_fieldset( & $Form, & $LinkOwner, $fold = false, $fi 'id' => $fieldset_prefix.$form_id, 'style' => 'display:none', // Show this uploader fieldset only when JS is enabled 'fold' => $fold, - 'deny_fold' => ( $links_count > 0 ) + 'deny_fold' => ( $links_count > 0 ), + 'data-fieldset-prefix' => $fieldset_prefix, ) ); echo '
    '; @@ -275,45 +275,47 @@ function display_attachments_fieldset( & $Form, & $LinkOwner, $fold = false, $fi $Form->end_fieldset(); // Show fieldset of quick uploader only when JS is enabled: - echo ''; - - if( is_logged_in() && $current_User->check_perm( 'admin', 'restricted' ) && $current_User->check_perm( 'files', 'view' ) && empty( $restriction_overlay ) ) + if( is_ajax_request() ) + { + echo ''; + } + else + { + expose_var_to_js( 'fieldset_'.$fieldset_prefix.$form_id, array( 'fieldset_prefix' => $fieldset_prefix, 'form_id' => $form_id ), 'evo_display_attachments_fieldset_config' ); + } + + if( check_user_perm( 'admin', 'restricted' ) && check_user_perm( 'files', 'view' ) && empty( $restriction_overlay ) ) { // Check if current user has a permission to back-office files manager: // Initialize JavaScript to build and open window: echo_modalwindow_js(); -?> - + ', '' ); + expose_var_to_js( 'evo_link_attachment_window_config', evo_json_encode( $link_attachment_window_config ) ); } - } ); - return false; -} - - '
    ', @@ -366,7 +368,7 @@ function display_attachments( & $LinkOwner, $params = array() ) echo ''; echo $link_File->get_view_link(); echo ''; - if( $current_User->check_perm( 'files', 'edit' ) ) + if( check_user_perm( 'files', 'edit' ) ) { // display delete link action $delete_url = get_htsrv_url().'action.php?mname=collections&action=unlink&link_ID='.$Link->ID.'&crumb_collections_unlink='.get_crumb( 'collections_unlink' ).'&redirect_to='.$redirect_to; echo action_icon( T_('Remove'), 'remove', $delete_url ); @@ -489,7 +491,7 @@ function link_actions( $link_ID, $row_idx_type = '', $link_type = 'item' ) * @var File */ global $current_File; - global $LinkOwner, $current_User; + global $LinkOwner; global $iframe_name, $admin_url, $blog; $r = ''; @@ -515,7 +517,7 @@ function link_actions( $link_ID, $row_idx_type = '', $link_type = 'item' ) 'data-link-id' => $link_ID ) ); } - if( $current_File && is_logged_in() && $current_User->check_perm( 'files', 'view', false, $current_File->get_FileRoot() ) ) + if( $current_File && check_user_perm( 'files', 'view', false, $current_File->get_FileRoot() ) ) { // Locate file $title = $current_File->dir_or_file( T_('Locate this directory!'), T_('Locate this file!') ); $url = $current_File->get_linkedit_url( $LinkOwner->type, $LinkOwner->get_ID() ); @@ -527,9 +529,9 @@ function link_actions( $link_ID, $row_idx_type = '', $link_type = 'item' ) .get_icon( 'locate', 'imgtag', array( 'title' => $title ) ).' '; } - if( $current_File && is_logged_in() && - $current_User->check_perm( 'admin', 'restricted' ) && - $current_User->check_perm( 'files', 'edit_allowed', false, $current_File->get_FileRoot() ) ) + if( $current_File && + check_user_perm( 'admin', 'restricted' ) && + check_user_perm( 'files', 'edit_allowed', false, $current_File->get_FileRoot() ) ) { // Edit file: $title = T_('Edit properties...'); $url = $current_File->get_linkedit_url( $LinkOwner->type, $LinkOwner->get_ID() ); @@ -671,25 +673,17 @@ function display_link_position( & $row, $show_actions = true, $fieldset_prefix = function echo_link_position_js() { global $Session; -?> - - 'select[id^=display_position_]', + 'url' => get_htsrv_url(), + 'crumb' => get_crumb( 'link' ), + 'alert_msg' => TS_('You can use the (+) icons to change the position to inline and automatically insert a short tag at the current cursor position.'), + 'display_inline_reminder' => $Session->get( 'display_inline_reminder', 'true' ), + 'defer_inline_reminder' => false, + ); + + expose_var_to_js( 'evo_link_position_config', json_encode( $evo_link_position_config ) ); } @@ -700,73 +694,30 @@ function echo_link_position_js() */ function echo_link_sortable_js( $fieldset_prefix = '' ) { -?> - -'] = ; + window.init_link_sortable( evo_link_sortable_js_config['link_sortable_'] ); + } ); + + get_by_ID( $link->link_itm_ID, false ) ) { $Collection = $Blog = $Item->get_Blog(); - if( $current_User->check_perm( 'item_post!CURSTATUS', 'view', false, $Item ) ) + if( check_user_perm( 'item_post!CURSTATUS', 'view', false, $Item ) ) { // Current user can edit the linked post $r .= $params['post_prefix'].''.$Item->get( 'title' ).''; } @@ -838,7 +789,7 @@ function get_file_links( $file_ID, $params = array() ) if( $Comment = & $CommentCache->get_by_ID( $link->link_cmt_ID, false ) ) { $Item = $Comment->get_Item(); - if( $current_User->check_perm( 'comment!CURSTATUS', 'moderate', false, $Comment ) ) + if( check_user_perm( 'comment!CURSTATUS', 'moderate', false, $Comment ) ) { // Current user can edit the linked Comment $r .= $params['comment_prefix'].''.$Item->get( 'title' ).''; } @@ -853,9 +804,24 @@ function get_file_links( $file_ID, $params = array() ) { // File is linked to user if( $User = & $UserCache->get_by_ID( $link->link_usr_ID, false ) ) { - if( $current_User->ID != $User->ID && !$current_User->check_perm( 'users', 'view' ) ) + if( $current_User->ID != $User->ID && ! check_user_perm( 'users', 'view' ) ) { // No permission to view other users in admin form - $r .= $params['user_prefix'].''.$User->get_username().''; + $BlogCache = & get_BlogCache(); + $BlogCache->load_user_blogs(); + $user_url = ''; + if( ! empty( $BlogCache->cache ) ) + { // Try to use alias user url: + foreach( $BlogCache->cache as $user_Blog ) + { // Use first found collection: + $user_url = $user_Blog->get( 'userurl', array( 'user_ID' => $User->ID, 'user_login' => $User->login ) ); + break; + } + } + if( empty( $user_url ) ) + { // Use standard user url: + $user_url = url_add_param( $baseurl, 'disp=user&user_ID='.$User->ID ); + } + $r .= $params['user_prefix'].''.$User->get_username().''; } else { // Build a link to display a user in admin form @@ -868,7 +834,7 @@ function get_file_links( $file_ID, $params = array() ) { // File is linked to email campaign: if( $EmailCampaign = & $EmailCampaignCache->get_by_ID( $link->link_ecmp_ID, false ) ) { - if( ! $current_User->check_perm( 'emails', 'view' ) ) + if( ! check_user_perm( 'emails', 'view' ) ) { // Build a link to display an email campaign in edit back-office form: $r .= $params['emailcampaign_prefix'].''.$EmailCampaign->get( 'name' ).''; } @@ -884,7 +850,7 @@ function get_file_links( $file_ID, $params = array() ) if( $Message = & $MessageCache->get_by_ID( $link->link_msg_ID, false ) ) { $Thread = & $Message->get_Thread(); - if( ! $current_User->check_perm( 'perm_messaging', 'reply' ) ) + if( ! check_user_perm( 'perm_messaging', 'reply' ) ) { // Build a link to display a message in edit back-office form: $r .= $params['message_prefix'].''.$Thread->get( 'title' ).' #'.$Message->ID.''; } @@ -1075,4 +1041,173 @@ function display_subtype( $link_ID ) return $Link->get_preview_thumb(); } + +/** + * Display attachments tab pane + * + * @param object Form + * @param object LinkOwner object + * @param boolean true to allow folding for this fieldset, false otherwise + * @param string Tab pane prefix + */ +function display_attachments_tab_pane( & $Form, & $LinkOwner, $fold = false, $tab_pane_prefix = '' ) +{ + global $admin_url, $inc_path; + global $current_User, $action; + + if( ! isset( $GLOBALS[ 'files_Module' ] ) ) + { // Files module is not enabled: + return; + } + + if( ! $LinkOwner->check_perm( 'edit', false ) ) + { // Current user has no perm to edit the link owner: + return; + } + + // Set title for modal window: + switch( $LinkOwner->type ) + { + case 'item': + if( $LinkOwner->is_temp() ) + { + $window_title = ''; + } + else + { + $window_title = format_to_js( sprintf( T_('Attach files to "%s"'), $LinkOwner->Item->get( 'title' ) ) ); + if( ! $LinkOwner->Item->check_proposed_change_restriction() ) + { // Display overlay if the Item has a restriction by existing proposed change: + $restriction_overlay = T_('You must save the post and/or accept the proposed changes before you can edit the attachments.'); + } + } + $form_id = 'itemform_links'; + break; + + case 'comment': + $window_title = $LinkOwner->is_temp() ? '' : format_to_js( sprintf( T_('Attach files to comment #%s'), $LinkOwner->Comment->ID ) ); + $form_id = 'cmntform_links'; + break; + + case 'emailcampaign': + $window_title = format_to_js( sprintf( T_('Attach files to email campaign "%s"'), $LinkOwner->EmailCampaign->get( 'name' ) ) ); + $form_id = 'ecmpform_links'; + break; + + case 'message': + $window_title = ''; + $form_id = 'msgform_links'; + break; + + default: + $window_title = ''; + $form_id = 'atchform_links'; + break; + } + + $items_left = ''; + $items_right = ''; + + if( is_admin_page() ) + { // Display a link to manual page only on back-office: + $items_right .= ' '.get_manual_link( 'images-attachments-panel' ); + } + + if( is_logged_in() && $current_User->check_perm( 'admin', 'restricted' ) && $current_User->check_perm( 'files', 'view' ) ) + { // Check if current user has a permission to back-office files manager: + $attach_files_url = $admin_url.'?ctrl=files&fm_mode=link_object&link_type='.( $LinkOwner->is_temp() ? 'temporary' : $LinkOwner->type ).( $LinkOwner->type != 'message' ? '&link_object_ID='.$LinkOwner->get_ID() : '' ); + if( $linkowner_FileList = $LinkOwner->get_attachment_FileList( 1 ) ) + { // Get first file of the Link Owner: + $linkowner_File = & $linkowner_FileList->get_next(); + if( ! empty( $linkowner_File ) && $current_User->check_perm( 'files', 'view', false, $linkowner_File->get_FileRoot() ) ) + { // Obtain and use file root of first file: + $linkowner_FileRoot = & $linkowner_File->get_FileRoot(); + $attach_files_url .= '&root='.$linkowner_FileRoot->ID; + $attach_files_url .= '&path='.dirname( $linkowner_File->get_rdfs_rel_path() ).'/'; + } + } + $items_left .= action_icon( T_('Attach existing files'), 'folder', $attach_files_url, + T_('Attach existing files'), 3, 4, + array( 'onclick' => 'return link_attachment_window( \''.( $LinkOwner->is_temp() ? 'temporary' : $LinkOwner->type ).'\', \''.$LinkOwner->get_ID().'\', \'\', \'\', \'\', \''.$tab_pane_prefix.'\' )' ) ); + if( ! $LinkOwner->is_temp() ) + { // Don't allow this option for new creating objects: + $items_left .= action_icon( T_('Attach existing files'), 'permalink', $attach_files_url, + T_('Attach existing files'), 1, 0, + array( 'target' => '_blank' ) ); + } + } + + $items_right .= action_icon( T_('Refresh'), 'refresh', $LinkOwner->get_edit_url(), + T_('Refresh'), 3, 4, array( 'class' => 'action_icon btn btn-default btn-sm', 'onclick' => 'return evo_link_refresh_list( \''.( $LinkOwner->is_temp() ? 'temporary' : $LinkOwner->type ).'\', \''.$LinkOwner->get_ID().'\' )' ) ) + + .action_icon( T_('Sort'), 'ascending', ( is_admin_page() || ( is_logged_in() && $current_User->check_perm( 'admin', 'restricted' ) ) ) + ? $admin_url.'?ctrl=links&action=sort_links&link_type='.$LinkOwner->type.'&link_object_ID='.$LinkOwner->get_ID().'&'.url_crumb( 'link' ) + : $LinkOwner->get_edit_url().'#', + T_('Sort'), 3, 4, array( 'class' => 'action_icon btn btn-default btn-sm', 'onclick' => 'return evo_link_refresh_list( \''.( $LinkOwner->is_temp() ? 'temporary' : $LinkOwner->type ).'\', \''.$LinkOwner->get_ID().'\', \'sort\' )' ) ); + + // Get a count of links in order to deny folding when there is at least one link + $links_count = count( $LinkOwner->get_Links() ); + $Form->open_tab_pane( array( + 'id' => 'attachment', + 'class' => 'in active tab_pane_no_pads', + 'left_items' => $items_left, + 'right_items' => $items_right, + ) ); + + echo '
    '; + if( ! empty( $restriction_overlay ) ) + { // Restrict attachments with overlay: + echo '
    '.$restriction_overlay.'
    '; + } + echo '
    '; + echo '
    '; + require $inc_path.'links/views/_link_list.view.php'; + echo '
    '; + echo '
    '; + echo '
    '; + + $Form->close_tab_pane(); + + // Show fieldset of quick uploader only when JS is enabled: + echo ''; + + if( is_logged_in() && $current_User->check_perm( 'admin', 'restricted' ) && $current_User->check_perm( 'files', 'view' ) && empty( $restriction_overlay ) ) + { // Check if current user has a permission to back-office files manager: + + // Initialize JavaScript to build and open window: + echo_modalwindow_js(); +?> + + diff --git a/inc/links/model/_linkcomment.class.php b/inc/links/model/_linkcomment.class.php index cc764b52f7a..fda146c838b 100644 --- a/inc/links/model/_linkcomment.class.php +++ b/inc/links/model/_linkcomment.class.php @@ -66,8 +66,6 @@ function __construct( $Comment, $tmp_ID = NULL ) */ function check_perm( $permlevel, $assert = false, $FileRoot = NULL ) { - global $current_User; - $r = false; if( $permlevel == 'add' ) @@ -82,9 +80,8 @@ function check_perm( $permlevel, $assert = false, $FileRoot = NULL ) } else { // Check permission for existing comment in DB: - $r = is_logged_in() && ( - ( $this->Comment->is_meta() && $current_User->check_perm( 'meta_comment', $permlevel, $assert, $this->Comment ) ) || - $current_User->check_perm( 'blog_comments', $permlevel, $assert, $this->get_blog_ID() ) ); + $r = ( $this->Comment->is_meta() && check_user_perm( 'meta_comment', $permlevel, $assert, $this->Comment ) ) || + check_user_perm( 'blog_comments', $permlevel, $assert, $this->get_blog_ID() ); } if( ! $r && $assert ) diff --git a/inc/links/model/_linkemailcampaign.class.php b/inc/links/model/_linkemailcampaign.class.php index 8aa3437f62a..92930685ef7 100644 --- a/inc/links/model/_linkemailcampaign.class.php +++ b/inc/links/model/_linkemailcampaign.class.php @@ -58,8 +58,6 @@ function __construct( $EmailCampaign ) */ function check_perm( $permlevel, $assert = false, $FileRoot = NULL ) { - global $current_User; - if( ! is_logged_in() ) { // User must be logged in: if( $assert ) @@ -71,10 +69,10 @@ function check_perm( $permlevel, $assert = false, $FileRoot = NULL ) if( $permlevel == 'add' ) { // Check permission to add/upload new files: - return $current_User->check_perm( 'files', $permlevel, $assert, $FileRoot ); + return check_user_perm( 'files', $permlevel, $assert, $FileRoot ); } - return $current_User->check_perm( 'emails', $permlevel, $assert ); + return check_user_perm( 'emails', $permlevel, $assert ); } /** diff --git a/inc/links/model/_linkitem.class.php b/inc/links/model/_linkitem.class.php index 4e80e0dbd5e..2f7d323797e 100644 --- a/inc/links/model/_linkitem.class.php +++ b/inc/links/model/_linkitem.class.php @@ -61,8 +61,6 @@ function __construct( $Item, $tmp_ID = NULL ) */ function check_perm( $permlevel, $assert = false, $FileRoot = NULL ) { - global $current_User; - if( ! is_logged_in() ) { // User must be logged in: if( $assert ) @@ -74,16 +72,16 @@ function check_perm( $permlevel, $assert = false, $FileRoot = NULL ) if( $permlevel == 'add' ) { // Check permission to add/upload new files: - return $current_User->check_perm( 'files', $permlevel, $assert, $FileRoot ); + return check_user_perm( 'files', $permlevel, $assert, $FileRoot ); } if( $this->is_temp() ) { // Check permission for new creating item: - return $current_User->check_perm( 'blog_post_statuses', $permlevel, $assert, $this->get_blog_ID() ); + return check_user_perm( 'blog_post_statuses', $permlevel, $assert, $this->get_blog_ID() ); } else { // Check permission for existing item in DB: - return $current_User->check_perm( 'item_post!CURSTATUS', $permlevel, $assert, $this->Item ); + return check_user_perm( 'item_post!CURSTATUS', $permlevel, $assert, $this->Item ); } } @@ -100,9 +98,10 @@ function get_positions( $file_ID = NULL ) $FileCache = & get_FileCache(); $File = $FileCache->get_by_ID( $file_ID, false, false ); if( $File && $File->is_image() ) - { // Only images can have this position + { // Only images can have these positions: // TRANS: Noun - we're talking about a cover image i-e: an image that used as cover for a post $positions['cover'] = T_('Cover'); + $positions['background'] = T_('Background'); } $positions = array_merge( $positions, array( diff --git a/inc/links/model/_linkmessage.class.php b/inc/links/model/_linkmessage.class.php index 36f1b0e3267..45f36f6c6e5 100644 --- a/inc/links/model/_linkmessage.class.php +++ b/inc/links/model/_linkmessage.class.php @@ -61,8 +61,6 @@ function __construct( $Message, $tmp_ID = NULL ) */ function check_perm( $permlevel, $assert = false, $FileRoot = NULL ) { - global $current_User; - if( ! is_logged_in() ) { // User must be logged in: if( $assert ) @@ -74,10 +72,10 @@ function check_perm( $permlevel, $assert = false, $FileRoot = NULL ) if( $permlevel == 'add' ) { // Check permission to add/upload new files: - return $current_User->check_perm( 'files', $permlevel, $assert, $FileRoot ); + return check_user_perm( 'files', $permlevel, $assert, $FileRoot ); } - return $current_User->check_perm( 'perm_messaging', 'reply', $assert ); + return check_user_perm( 'perm_messaging', 'reply', $assert ); } diff --git a/inc/links/model/_linkuser.class.php b/inc/links/model/_linkuser.class.php index ca2c38e3664..d19504ed760 100644 --- a/inc/links/model/_linkuser.class.php +++ b/inc/links/model/_linkuser.class.php @@ -68,10 +68,10 @@ function check_perm( $permlevel, $assert = false, $FileRoot = NULL ) if( $permlevel == 'add' ) { // Check permission to add/upload new files: - return $current_User->check_perm( 'files', $permlevel, $assert, $FileRoot ); + return check_user_perm( 'files', $permlevel, $assert, $FileRoot ); } - return $current_User->ID == $this->User->ID || $current_User->check_perm( 'users', $permlevel, $assert ); + return $current_User->ID == $this->User->ID || check_user_perm( 'users', $permlevel, $assert ); } /** diff --git a/inc/links/views/_link_file_list.inc.php b/inc/links/views/_link_file_list.inc.php new file mode 100644 index 00000000000..ae513f417a2 --- /dev/null +++ b/inc/links/views/_link_file_list.inc.php @@ -0,0 +1,390 @@ + + + + + '; + + echo ''; + + if( $fm_flatmode ) + { + echo ''; + } + + echo ''; + + if( $UserSettings->get('fm_showtypes') ) + { // Show file types column + echo ''; + } + + if( $UserSettings->get('fm_showcreator') ) + { // Show file creator + echo ''; + } + + if( $UserSettings->get('fm_showdownload') ) + { // Show download count column + echo ''; + } + + echo ''; + + echo ''; + + if( $UserSettings->get('fm_showdate') != 'no' ) + { // Show last mod column + echo ''; + } + + if( $UserSettings->get('fm_showfsperms') ) + { // Show file perms column + echo ''; + } + + if( $UserSettings->get('fm_showfsowner') ) + { // Show file owner column + echo ''; + } + + if( $UserSettings->get('fm_showfsgroup') ) + { // Show file group column + echo ''; + } + + echo ''; + echo ''; + ?> + + get_total_rows() > 0 ) + { // Display table headers only when at least file is found in the selected folder and filter: + echo $table_headers; + } + ?> + + get_next() ) + { // Loop through all Files: + $lFile = & $lLink->get_File(); + + if( $lFile->is_dir() ) + { // Skip directories: + continue; + } + + $lLinkOwner = & $lLink->get_LinkOwner(); + $row_class = array(); + if( ( get_class( $lLinkOwner->link_Object ) == 'Comment' ) && $lLinkOwner->link_Object->is_meta() ) + { // Show different background color for internal comments: + $row_class[] = 'bg-info'; + } + echo 'get_name() == $fm_highlight ) + { // We want a specific file to be highlighted (user clicked on "locate"/target icon + echo ' id="fm_highlighted"'; // could be a class, too.. + } + echo '>'; + + + /******************** Icon / File type: *******************/ + + echo ''; + evo_flush(); + + /******************* Path (flatmode): ******************/ + + if( $fm_flatmode ) + { + echo ''; + evo_flush(); + } + + /******************* File name: ******************/ + if( ! $fm_flatmode || + ( $selected_Filelist->get_rds_list_path() === false && dirname( $lFile->get_rdfs_rel_path() ) == '.' ) || + ( $selected_Filelist->get_rds_list_path() == dirname( $lFile->get_rdfs_rel_path() ).'/' ) ) + { // Use a hidden field only for current folder and not for subfolders + // It is used to detect a duplicate file on quick upload + $filename_hidden_field = ''; + } + else + { // Don't use the hidden field for this file because it is from another folder + $filename_hidden_field = ''; + } + echo ''; + evo_flush(); + + /******************* File type ******************/ + + if( $UserSettings->get( 'fm_showtypes' ) ) + { // Show file types + echo ''; + evo_flush(); + } + + /******************* Added by *******************/ + + if( $UserSettings->get( 'fm_showcreator' ) ) + { + if( $creator = $lFile->get_creator() ) + { + echo ''; + } + else + { + echo ''; + } + evo_flush(); + } + + /**************** Download Count ****************/ + + if( $UserSettings->get( 'fm_showdownload' ) ) + { // Show download count + // erhsatingin> Can't seem to find proper .less file to add the 'download' class, using class 'center' instead + echo ''; + evo_flush(); + } + + /******************* Link / Item date ******************/ + + $owner_date = ''; + switch( get_class( $lLinkOwner->link_Object ) ) + { + case 'Comment': + case 'Item': + case 'EmailCampaign': + $owner_date = $lLinkOwner->link_Object->get_creation_time(); + break; + } + echo ''; + + /******************* File size ******************/ + + echo ''; + + /**************** File time stamp ***************/ + + if( $UserSettings->get( 'fm_showdate' ) != 'no' ) + { // Show last modified datetime (always full in title attribute) + $lastmod_date = $lFile->get_lastmod_formatted( 'date' ); + $lastmod_time = $lFile->get_lastmod_formatted( 'time' ); + echo ''; + evo_flush(); + } + + /**************** File pemissions ***************/ + + if( $UserSettings->get( 'fm_showfsperms' ) ) + { // Show file perms + echo ''; + evo_flush(); + } + + /**************** File owner ********************/ + + if( $UserSettings->get( 'fm_showfsowner' ) ) + { // Show file owner + echo ''; + evo_flush(); + } + + /**************** File group *********************/ + + if( $UserSettings->get( 'fm_showfsgroup' ) ) + { // Show file owner + echo ''; + evo_flush(); + } + + /***************** Action icons ****************/ + + echo ''; + evo_flush(); + + echo ''; + evo_flush(); + + + $countFiles++; + } + // End of file list.. + + + /** + * @global integer Number of cols for the files table, 5 is minimum. + */ + $filetable_cols = 5 + + ( int ) $fm_flatmode + + ( int ) $UserSettings->get( 'fm_showcreator' ) + + ( int ) $UserSettings->get( 'fm_showtypes' ) + + ( int ) ( $UserSettings->get( 'fm_showdate' ) != 'no' ) + + ( int ) $UserSettings->get( 'fm_showfsperms' ) + + ( int ) $UserSettings->get( 'fm_showfsowner' ) + + ( int ) $UserSettings->get( 'fm_showfsgroup' ) + + ( int ) $UserSettings->get( 'fm_showdownloads' ) + + ( int ) $UserSettings->get( 'fm_imglistpreview' ); + + $noresults = ''; + if( $countFiles == 0 ) + { // Filelist errors or "directory is empty": + $noresults = ' + + '; + // Note: this var is also used for display_dragdrop_upload_button() below: + echo $noresults; + } + + echo ''; + ?> +
    '; + if( $UserSettings->get( 'fm_imglistpreview' ) ) + { // Image file preview: + $col_title = T_('Icon/Type'); + } + else + { + $col_title = /* TRANS: short for (file)Type */ T_('T '); // Not to be confused with T for Tuesday + } + echo $col_title; + echo ''./* TRANS: file/directory path */ T_('Path').''./* TRANS: file name */ T_('Name').''./* TRANS: file type */ T_('Type').''./* TRANS: added by */ T_('Added by').''./* TRANS: download count */ T_('Downloads').''./* TRANS: creation date of source Item or Comment */ T_('Date created').''./* TRANS: file size */ T_('Size').''./* TRANS: file's last change / timestamp */ T_('Last change').''./* TRANS: file's permissions (short) */ T_('Perms').''./* TRANS: file owner */ T_('Owner').''./* TRANS: file group */ T_('Group').''. /* TRANS: file actions; edit, rename, copy, .. */ T_('Actions').'
    '; + if( $UserSettings->get( 'fm_imglistpreview' ) ) + { // Image preview OR full type: + echo $lFile->get_preview_thumb( 'fulltype', array( 'init' => true ) ); + } + else + { // No image preview, small type: + echo $lFile->get_view_link( $lFile->get_icon(), NULL, $lFile->get_icon() ); + } + echo ''; + echo dirname( $lFile->get_rdfs_rel_path() ).'/'; + echo '' + .$filename_hidden_field; + + /************* Invalid filename warning: *************/ + + if( !$lFile->is_dir() ) + { + if( $error_filename = validate_filename( $lFile->get_name() ) ) + { // TODO: Warning icon with hint + echo get_icon( 'warning', 'imgtag', array( 'class' => 'filenameIcon', 'title' => strip_tags( $error_filename ), 'data-toggle' => 'tooltip' ) ).' '; + syslog_insert( sprintf( 'The unrecognized extension is detected for file %s', '[['.$lFile->get_name().']]' ), 'warning', 'file', $lFile->ID ); + } + } + + /*************** Link ("chain") icon: **************/ + + // Only provide link/"chain" icons for files. + + // fp> here might not be the best place to put the perm check + if( isset( $LinkOwner ) && $LinkOwner->check_perm( 'edit' ) ) + { // Offer option to link the file to an Item (or anything else): + $link_attribs = array( 'class' => 'action_icon link_file btn btn-primary btn-xs' ); + $link_action = 'link'; + if( $mode == 'upload' ) + { // We want the action to happen in the post attachments iframe: + $link_attribs['target'] = $iframe_name; + $link_attribs['onclick'] = 'return evo_link_attach( \''.$LinkOwner->type.'\', '.$LinkOwner->get_ID() + .', \''.FileRoot::gen_ID( $fm_Filelist->get_root_type(), $fm_Filelist->get_root_ID() ) + .'\', \''.$lFile->get_rdfp_rel_path().'\', \''.param( 'prefix', 'string' ).'\' )'; + $link_action = 'link_inpost'; + } + echo action_icon( T_('Link this file!'), 'link', + regenerate_url( 'fm_selected', 'action='.$link_action.'&fm_selected[]='.rawurlencode($lFile->get_rdfp_rel_path()).'&'.url_crumb('file') ), + ' '.T_('Attach'), NULL, 5, $link_attribs ); + echo ' '; + } + + /******************** File name + meta data ********************/ + echo file_td_name( $lFile ); + + echo ''.$lFile->get_type().''.$creator->get( 'login' ).'unknown'.$lFile->get_download_count().''.$owner_date.''.$fm_Filelist->get_File_size_formatted( $lFile ).''; + echo file_td_lastmod( $lFile ); + echo ''; + $fm_permlikelsl = $UserSettings->param_Request( 'fm_permlikelsl', 'fm_permlikelsl', 'integer', 0 ); + echo $lFile->get_perms( $fm_permlikelsl ? 'lsl' : '' ); + echo ''; + echo $lFile->get_fsowner_name(); + echo ''; + echo $lFile->get_fsgroup_name(); + echo ''; + echo file_td_actions( $lFile, array( 'move', 'copy', 'delete' ) ); + echo '
    ' + .T_('No files found.') + .( $fm_Filelist->is_filtering() ? '
    '.T_('Filter').': «'.$fm_Filelist->get_filter().'»' : '' ) + .'
    + diff --git a/inc/links/views/_link_list.inc.php b/inc/links/views/_link_list.inc.php index 00d5f5a04fa..b2dfac636f3 100644 --- a/inc/links/views/_link_list.inc.php +++ b/inc/links/views/_link_list.inc.php @@ -109,7 +109,7 @@ function display_link() ); -if( $current_User->check_perm( 'files', 'view' ) ) +if( check_user_perm( 'files', 'view' ) ) { function file_actions( $link_ID ) { @@ -117,11 +117,11 @@ function file_actions( $link_ID ) * @var File */ global $current_File; - global $LinkOwner, $current_User; + global $LinkOwner; $r = ''; - if( ! empty( $current_File ) && $current_User->check_perm( 'files', 'view', false, $current_File->get_FileRoot() ) ) + if( ! empty( $current_File ) && check_user_perm( 'files', 'view', false, $current_File->get_FileRoot() ) ) { if( $current_File->is_dir() ) $title = T_('Locate this directory!'); @@ -145,7 +145,7 @@ function file_actions( $link_ID ) ); } -if( $current_User->check_perm( 'files', 'view' ) +if( check_user_perm( 'files', 'view' ) && $LinkOwner->check_perm( 'edit' ) ) { // Check that we have permission to edit LinkOwner object: $Results->global_icon( T_('Link a file...'), 'link', url_add_param( $Blog->get_filemanager_link(), diff --git a/inc/links/views/_link_list.view.php b/inc/links/views/_link_list.view.php index 2e3d0d56dec..35d331f6bb6 100644 --- a/inc/links/views/_link_list.view.php +++ b/inc/links/views/_link_list.view.php @@ -157,13 +157,14 @@ // Display a button to quick upload the files by drag&drop method display_dragdrop_upload_button( array( - 'before' => '
    ', - 'after' => '
    ', - 'fileroot_ID' => $upload_fileroot, - 'path' => $upload_path, - 'listElement' => 'jQuery( "#'.$fieldset_prefix.'attachments_fieldset_table .filelist_tbody" ).get(0)', - 'list_style' => 'table', - 'template' => '
    ' + 'before' => '
    ', + 'after' => '
    ', + 'fileroot_ID' => $upload_fileroot, + 'path' => $upload_path, + 'listElement' => 'jQuery( "#'.$fieldset_prefix.'attachments_fieldset_table .filelist_tbody" ).get(0)', + 'list_element' => '#'.$fieldset_prefix.'attachments_fieldset_table .filelist_tbody', + 'list_style' => 'table', + 'template' => '
    ' .'
    ' // Main dropzone // The div below is not necessary because were making the main dropzone transparent so // the upload button below will not be covered when the main dropzone is "displayed" on drop ((see qq-hide-dropzone doc)): @@ -207,10 +208,23 @@ 'fm_mode' => $fm_mode, 'fieldset_prefix' => $fieldset_prefix, ) ); + + if( ! isset( $attachment_tab ) ) + { + // Initialize attachments fieldset to set proper height and handler to resize it: + if( is_ajax_request() ) + { + ?> + + $fieldset_prefix ), 'evo_link_initialize_fieldset_config' ); + } + } ?> - diff --git a/inc/locales/_locale.funcs.php b/inc/locales/_locale.funcs.php index 5af284428ed..e6d489bb70f 100644 --- a/inc/locales/_locale.funcs.php +++ b/inc/locales/_locale.funcs.php @@ -1086,7 +1086,7 @@ function locale_overwritefromDB() */ function locale_updateDB() { - global $locales, $DB, $Settings, $Messages, $action, $current_User, $admin_url; + global $locales, $DB, $Settings, $Messages, $action, $admin_url; global $saved_params; $templocales = $locales; @@ -1195,7 +1195,7 @@ function locale_updateDB() foreach( $main_locale_coll_IDs as $main_locale_coll_ID ) { $locale_Blog = & $BlogCache->get_by_ID( $main_locale_coll_ID ); - $coll_url = $current_User->check_perm( 'blog_properties', 'edit', false, $main_locale_coll_ID ) + $coll_url = check_user_perm( 'blog_properties', 'edit', false, $main_locale_coll_ID ) ? $admin_url.'?ctrl=coll_settings&tab=general&blog='.$locale_Blog->ID.'#fieldset_wrapper_language' : $locale_Blog->get( 'url' ); $warning_message .= '
  • '.$locale_Blog->get( 'name' ).'
  • '; @@ -1224,7 +1224,7 @@ function locale_updateDB() foreach( $extra_locale_coll_IDs as $extra_locale_coll_ID ) { $locale_Blog = & $BlogCache->get_by_ID( $extra_locale_coll_ID ); - $coll_url = $current_User->check_perm( 'blog_properties', 'edit', false, $extra_locale_coll_ID ) + $coll_url = check_user_perm( 'blog_properties', 'edit', false, $extra_locale_coll_ID ) ? $admin_url.'?ctrl=coll_settings&tab=general&blog='.$locale_Blog->ID.'#fieldset_wrapper_language' : $locale_Blog->get( 'url' ); $warning_message .= '
  • '.$locale_Blog->get( 'name' ).'
  • '; diff --git a/inc/locales/_locale_settings.form.php b/inc/locales/_locale_settings.form.php index 9f0684cde96..1ab9134329d 100644 --- a/inc/locales/_locale_settings.form.php +++ b/inc/locales/_locale_settings.form.php @@ -15,10 +15,6 @@ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); -/** - * @var User - */ -global $current_User; /** * @var GeneralSettings */ @@ -260,7 +256,7 @@ $messages_pot_file_info['messages.pot']['all'].' '.$button_generate_POT_file, $messages_DB_info.' '.$button_import_POT_file ).'
    '; - if( $current_User->check_perm( 'options', 'edit' ) && !$allow_po_extraction ) + if( check_user_perm( 'options', 'edit' ) && !$allow_po_extraction ) { echo ''; echo TB_('To allow the extraction of language files, please set $allow_po_extraction = 1; in conf/_locales.php.'); @@ -291,7 +287,7 @@ title=""> > - check_perm( 'options', 'edit' ) ) + > check_perm( 'options', 'edit' ) && $allow_po_extraction ) + if( check_user_perm( 'options', 'edit' ) && $allow_po_extraction ) { echo ''.TB_('Extract').''; } @@ -452,12 +448,12 @@ locale_flag( $lkey ); echo' '; - if( $current_User->check_perm( 'options', 'edit' ) ) + if( check_user_perm( 'options', 'edit' ) ) { echo ''; } echo $lkey; - if( $current_User->check_perm( 'options', 'edit' ) ) + if( check_user_perm( 'options', 'edit' ) ) { echo ''; } @@ -489,7 +485,7 @@ echo ''.$locale_data['priority'].''; - if( $current_User->check_perm( 'options', 'edit' ) ) + if( check_user_perm( 'options', 'edit' ) ) { if( $loc_transinfo ) { @@ -551,7 +547,7 @@ $po_file = $locales_path.$locale_data['messages'].'/LC_MESSAGES/'.$po_file; if( ! is_file( $po_file ) ) { - echo ''.TB_('No PO file').''; + echo ''.TB_('No PO file').''; } else { // File exists: @@ -566,7 +562,7 @@ } } - if( $current_User->check_perm( 'options', 'edit' ) && $allow_po_extraction ) + if( check_user_perm( 'options', 'edit' ) && $allow_po_extraction ) { // Translator options: if( is_file( $po_file ) ) { @@ -585,7 +581,7 @@ echo ''; - if( $current_User->check_perm( 'options', 'edit' ) ) + if( check_user_perm( 'options', 'edit' ) ) { echo '

    '.get_icon( 'new' ).' '.TB_('Create new locale').'

    '; @@ -598,7 +594,7 @@ $Form->end_fieldset(); - if( $current_User->check_perm( 'options', 'edit' ) ) + if( check_user_perm( 'options', 'edit' ) ) { $Form->end_form( array( array( 'submit', 'submit', TB_('Save Changes!'), 'SaveButton' ) ) ); } diff --git a/inc/locales/locales.ctrl.php b/inc/locales/locales.ctrl.php index f274f902ae8..19cff9afdbd 100644 --- a/inc/locales/locales.ctrl.php +++ b/inc/locales/locales.ctrl.php @@ -15,8 +15,8 @@ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); // Check minimum permission: -$current_User->check_perm( 'admin', 'normal', true ); -$current_User->check_perm( 'options', 'view', true ); +check_user_perm( 'admin', 'normal', true ); +check_user_perm( 'options', 'view', true ); load_funcs('locales/model/_translation.funcs.php'); @@ -53,7 +53,7 @@ $Session->assert_received_crumb( 'locales' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // If default locale has not been selected on form use default locale from config var $default_locale: param( 'newdefault_locale', 'string', $default_locale ); @@ -78,7 +78,7 @@ $Session->assert_received_crumb( 'locales' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); param( 'newloc_locale', 'string', true ); param_check_regexp( 'newloc_locale', '/^[a-z]{2,3}-[A-Z]{2}.*$/', TB_('Please use valid locale format.') ); @@ -247,7 +247,7 @@ $Session->assert_received_crumb( 'locales' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); $nofile_locales = array(); if( is_array( $locales ) ) @@ -319,7 +319,7 @@ $Session->assert_received_crumb( 'locales' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Get PO file for that edit_locale: $AdminUI->append_to_titlearea( sprintf( TB_('Extracting language file for %s...'), ''.$edit_locale.'' ) ); @@ -399,7 +399,7 @@ $Session->assert_received_crumb( 'locales' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); $edit_locale_messages = ( empty( $locales[ $edit_locale ]['messages'] ) ) ? $edit_locale : str_replace( '-', '_', $locales[ $edit_locale ]['messages'] ); $edit_locale_path = $locales_path.$edit_locale_messages.'/'.$edit_locale.'.locale.php'; @@ -445,7 +445,7 @@ $Session->assert_received_crumb( 'locales' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); if( isset( $locales ) && isset( $locales[ $edit_locale ] ) && ! empty( $locales[ $edit_locale ]['enabled'] ) ) @@ -490,7 +490,7 @@ $Session->assert_received_crumb( 'locales' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); $switchcond = ''; if( $action == 'prioup' ) diff --git a/inc/locales/translation.ctrl.php b/inc/locales/translation.ctrl.php index b51545d4ac1..7166b6a57e5 100644 --- a/inc/locales/translation.ctrl.php +++ b/inc/locales/translation.ctrl.php @@ -14,8 +14,8 @@ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); // Check minimum permission: -$current_User->check_perm( 'admin', 'normal', true ); -$current_User->check_perm( 'options', 'view', true ); +check_user_perm( 'admin', 'normal', true ); +check_user_perm( 'options', 'view', true ); load_funcs('locales/model/_translation.funcs.php'); diff --git a/inc/locales/views/_translation.view.php b/inc/locales/views/_translation.view.php index 9076d80a6cc..31ca8d99db0 100644 --- a/inc/locales/views/_translation.view.php +++ b/inc/locales/views/_translation.view.php @@ -17,7 +17,7 @@ /** * @var User */ -global $admin_url, $current_User; +global $admin_url; global $edit_locale; @@ -149,7 +149,7 @@ function iost_td_actions( $row ) echo '
    '; -if( $current_User->check_perm( 'options', 'edit' ) ) +if( check_user_perm( 'options', 'edit' ) ) { global $locales_path, $locales; diff --git a/inc/locales/views/_translation_new.view.php b/inc/locales/views/_translation_new.view.php index 3e45007e0e3..5b2e59994d7 100644 --- a/inc/locales/views/_translation_new.view.php +++ b/inc/locales/views/_translation_new.view.php @@ -17,7 +17,7 @@ /** * @var User */ -global $admin_url, $current_User; +global $admin_url; global $edit_locale; diff --git a/inc/maintenance/_maintenance.init.php b/inc/maintenance/_maintenance.init.php index af16db48796..c69e27d663d 100644 --- a/inc/maintenance/_maintenance.init.php +++ b/inc/maintenance/_maintenance.init.php @@ -161,14 +161,14 @@ function check_maintenance_group_perm( $permlevel, $permvalue, $permtarget ) */ function build_menu_3() { - global $AdminUI, $current_User, $auto_upgrade_from_any_url; + global $AdminUI, $auto_upgrade_from_any_url; - if( !$current_User->check_perm( 'admin', 'normal' ) ) + if( ! check_user_perm( 'admin', 'normal' ) ) { return; } - if( $current_User->check_perm( 'maintenance', 'backup' ) ) + if( check_user_perm( 'maintenance', 'backup' ) ) { // Display Backup tab in System -> Maintenance menu $AdminUI->add_menu_entries( array( 'options', 'misc' ), array( @@ -178,7 +178,7 @@ function build_menu_3() ) ); } - if( $current_User->check_perm( 'maintenance', 'upgrade' ) ) + if( check_user_perm( 'maintenance', 'upgrade' ) ) { // Display Updates tab in System -> Maintenance menu $AdminUI->add_menu_entries( array( 'options', 'misc' ), array( diff --git a/inc/maintenance/backup.ctrl.php b/inc/maintenance/backup.ctrl.php index 53761216c07..ace27b9c747 100644 --- a/inc/maintenance/backup.ctrl.php +++ b/inc/maintenance/backup.ctrl.php @@ -17,14 +17,10 @@ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); -/** - * @var instance of User class - */ -global $current_User; // Check minimum permission: -$current_User->check_perm( 'admin', 'normal', true ); -$current_User->check_perm( 'maintenance', 'backup', true ); +check_user_perm( 'admin', 'normal', true ); +check_user_perm( 'maintenance', 'backup', true ); // Load Backup class (PHP4): load_class( 'maintenance/model/_backup.class.php', 'Backup' ); diff --git a/inc/maintenance/model/_maintenance.funcs.php b/inc/maintenance/model/_maintenance.funcs.php index 6cabd5541b1..d6e1939fdd5 100644 --- a/inc/maintenance/model/_maintenance.funcs.php +++ b/inc/maintenance/model/_maintenance.funcs.php @@ -308,10 +308,10 @@ function unpack_archive( $src_file, $dest_dir, $mk_dest_dir = false, $src_file_n { global $Settings, $current_User, $basepath, $upgrade_path; - if( ! is_logged_in() || ! $current_User->check_perm( 'files', 'all' ) ) + if( ! check_user_perm( 'files', 'all' ) ) { // No permission to unzip files: $error = ''.TB_('You don\'t have permission to UNZIP files automatically on the server.').''; - if( $current_User->check_perm( 'users', 'edit' ) ) + if( check_user_perm( 'users', 'edit' ) ) { // Link to edit permissions: global $admin_url; $error .= ' ('.sprintf( TB_('You can change this here'), 'href="'.$admin_url.'?ctrl=groups&action=edit&grp_ID='.$current_User->get( 'grp_ID' ).'#fieldset_wrapper_file"' ).')'; diff --git a/inc/maintenance/upgrade.ctrl.php b/inc/maintenance/upgrade.ctrl.php index cb6f5a7471e..2c102aed46e 100644 --- a/inc/maintenance/upgrade.ctrl.php +++ b/inc/maintenance/upgrade.ctrl.php @@ -16,19 +16,14 @@ */ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); -/** - * @var instance of User class - */ -global $current_User; - /** * @vars string paths */ global $basepath, $upgrade_path, $install_path; // Check minimum permission: -$current_User->check_perm( 'admin', 'normal', true ); -$current_User->check_perm( 'maintenance', 'upgrade', true ); +check_user_perm( 'admin', 'normal', true ); +check_user_perm( 'maintenance', 'upgrade', true ); // Used in the upgrade process $script_start_time = $servertimenow; diff --git a/inc/maintenance/views/_upgrade_unzip.form.php b/inc/maintenance/views/_upgrade_unzip.form.php index 57d2266ceb6..22ca8f3c43e 100644 --- a/inc/maintenance/views/_upgrade_unzip.form.php +++ b/inc/maintenance/views/_upgrade_unzip.form.php @@ -40,7 +40,7 @@ elseif( $unzip_success ) { // Init the buttons to select next action $form_buttons[] = array( 'submit', 'actionArray[ready]', TB_('Skip Unzip'), 'SaveButton' ); - if( file_exists( $upgrade_file ) && $current_User->check_perm( 'files', 'all' ) ) + if( file_exists( $upgrade_file ) && check_user_perm( 'files', 'all' ) ) { // Allow to unzip only if current user has a permission to edit all files: $form_buttons[] = array( 'submit', 'actionArray[force_unzip]', TB_('Force New Unzip'), 'SaveButton btn-warning' ); } diff --git a/inc/menus/_menus.init.php b/inc/menus/_menus.init.php index 19d8c829b5c..7efd0d43a12 100644 --- a/inc/menus/_menus.init.php +++ b/inc/menus/_menus.init.php @@ -119,14 +119,14 @@ function init() */ function build_menu_2() { - global $admin_url, $current_User, $AdminUI; + global $admin_url, $AdminUI; - if( ! $current_User->check_perm( 'admin', 'restricted' ) ) + if( ! check_user_perm( 'admin', 'restricted' ) ) { // User must has an access to back-office: return; } - if( $current_User->check_perm( 'options', 'view' ) ) + if( check_user_perm( 'options', 'view' ) ) { // User has an access to view system settings: $AdminUI->add_menu_entries( array( 'site' ), array( 'menus' => array( diff --git a/inc/menus/menus.ctrl.php b/inc/menus/menus.ctrl.php index b671ea47eb3..ab56d63e710 100644 --- a/inc/menus/menus.ctrl.php +++ b/inc/menus/menus.ctrl.php @@ -18,7 +18,7 @@ load_class( 'menus/model/_sitemenuentrycache.class.php', 'SiteMenuEntryCache' ); // Check minimum permission: -$current_User->check_perm( 'options', 'view', true ); +check_user_perm( 'options', 'view', true ); $AdminUI->set_path( 'site', 'menus' ); @@ -72,7 +72,7 @@ $Session->assert_received_crumb( 'menu' ); // Check that current user has permission to create menus: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); if( $edited_SiteMenu && $edited_SiteMenu->duplicate() ) { @@ -90,7 +90,7 @@ $Session->assert_received_crumb( 'menu' ); // Check that current user has permission to create menus: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Load data from request: if( $edited_SiteMenu->load_from_Request() ) @@ -113,7 +113,7 @@ $Session->assert_received_crumb( 'menu' ); // Check that current user has permission to edit menus: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure we got an menu_ID: param( 'menu_ID', 'integer', true ); @@ -139,7 +139,7 @@ $Session->assert_received_crumb( 'menu' ); // Check that current user has permission to delete menus: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure we got an menu_ID: param( 'menu_ID', 'integer', true ); @@ -187,7 +187,7 @@ $Session->assert_received_crumb( 'menuentry' ); // Check that current user has permission to create menus: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Load data from request: if( $edited_SiteMenuEntry->load_from_Request() ) @@ -210,7 +210,7 @@ $Session->assert_received_crumb( 'menuentry' ); // Check that current user has permission to edit menus: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure we got an menu_ID: param( 'menu_ID', 'integer', true ); @@ -236,7 +236,7 @@ $Session->assert_received_crumb( 'menuentry' ); // Check that current user has permission to delete menus: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure we got an menu_ID: param( 'menu_ID', 'integer', true ); diff --git a/inc/menus/model/_menu.funcs.php b/inc/menus/model/_menu.funcs.php index 2e01c6a19ac..8af25929a68 100644 --- a/inc/menus/model/_menu.funcs.php +++ b/inc/menus/model/_menu.funcs.php @@ -49,10 +49,18 @@ function get_menu_types() 'visits' => T_('View my visits').' (disp=visits)', 'profile' => T_('Edit my profile').' (disp=profile)', 'avatar' => T_('Edit my profile picture').' (disp=avatar)', + 'password' => T_('Change my password').' (disp=pwdchange)', + 'userprefs' => T_('Change my preferences').' (disp=userprefs)', + 'usersubs' => T_('Notifications & Subscriptions').' (disp=subs)', 'useritems' => T_('View my posts/items').' (disp=useritems)', 'usercomments' => T_('View my comments').' (disp=usercomments)', ), + T_('Messaging') => array( + 'messages' => T_('Private messages'), + 'contacts' => T_('Messaging contacts'), + ), T_('Other') => array( + 'flagged' => T_('Flagged Items'), 'postnew' => T_('Create new Item').' (disp=edit)', 'admin' => T_('Go to Back-Office'), 'url' => T_('Go to any URL'), @@ -95,4 +103,70 @@ function get_site_menu_type_title( $type ) return $type; } + + +/** + * Get Site Menu ID by menu name or create default/demo Menu with entries + * + * @param string Site Menu name + * @return integer|FALSE Site Menu ID, FALSE if new menu cannot be created + */ +function get_default_site_menu_ID( $menu_name ) +{ + global $DB; + + if( ! $DB->get_var( 'SHOW TABLES LIKE "T_menus__menu"' ) ) + { // The Menus tables still doesn't exist, probably this is a call from old upgrade version: + return false; + } + + $SiteMenuCache = & get_SiteMenuCache(); + if( $SiteMenu = & $SiteMenuCache->get_by_name( $menu_name, false, false ) ) + { // Use existing Menu: + return $SiteMenu->ID; + } + + load_class( 'menus/model/_sitemenuentry.class.php', 'SiteMenuEntry' ); + + // Try to create Menu to Sitemap: + $SiteMenu = new SiteMenu(); + $SiteMenu->set( 'name', $menu_name ); + if( ! $SiteMenu->dbinsert() ) + { + return false; + } + + // Set default/demo menu entries depending on requested name: + switch( $menu_name ) + { + case 'Site Map - Common links': + $menu_entries = array( + array( 'type' => 'home', 'text' => T_('Home') ), + array( 'type' => 'recentposts', 'text' => T_('Recently') ), + array( 'type' => 'arcdir', 'text' => T_('Archives') ), + array( 'type' => 'mediaidx', 'text' => T_('Photo index') ), + array( 'type' => 'latestcomments', 'text' => T_('Latest comments') ), + array( 'type' => 'owneruserinfo', 'text' => T_('Owner details') ), + array( 'type' => 'ownercontact', 'text' => T_('Contact') ), + ); + break; + } + + if( isset( $menu_entries ) ) + { // Create default/demo menu entries: + $menu_entry_order = 10; + foreach( $menu_entries as $menu_entry ) + { + $SiteMenuEntry = new SiteMenuEntry(); + $SiteMenuEntry->set( 'menu_ID', $SiteMenu->ID ); + $SiteMenuEntry->set( 'type', $menu_entry['type'] ); + $SiteMenuEntry->set( 'text', $menu_entry['text'] ); + $SiteMenuEntry->set( 'order', $menu_entry_order ); + $SiteMenuEntry->dbinsert(); + $menu_entry_order += 10; + } + } + + return $SiteMenu->ID; +} ?> \ No newline at end of file diff --git a/inc/menus/model/_menus.install.php b/inc/menus/model/_menus.install.php index 432677ff31a..a1f8a2f67af 100644 --- a/inc/menus/model/_menus.install.php +++ b/inc/menus/model/_menus.install.php @@ -40,6 +40,7 @@ ment_menu_ID INT(10) UNSIGNED NOT NULL, ment_parent_ID INT(10) UNSIGNED NULL, ment_order INT(11) NULL, + ment_user_pic_size VARCHAR(32) COLLATE ascii_general_ci NULL, ment_text VARCHAR(128) COLLATE utf8mb4_unicode_ci NULL, ment_type VARCHAR(32) COLLATE ascii_general_ci NULL, ment_coll_logo_size VARCHAR(32) COLLATE ascii_general_ci NULL, @@ -49,7 +50,11 @@ ment_item_slug VARCHAR(255) COLLATE ascii_general_ci NULL, ment_url VARCHAR(2000) COLLATE utf8mb4_unicode_ci NULL, ment_visibility ENUM( 'always', 'access' ) COLLATE ascii_general_ci NOT NULL DEFAULT 'always', + ment_access ENUM( 'any', 'loggedin', 'perms' ) COLLATE ascii_general_ci NOT NULL DEFAULT 'perms', + ment_show_badge TINYINT(1) NOT NULL DEFAULT 1, ment_highlight TINYINT(1) NOT NULL DEFAULT 1, + ment_hide_empty TINYINT(1) NOT NULL DEFAULT 0, + ment_class VARCHAR(128) COLLATE ascii_general_ci NULL, PRIMARY KEY (ment_ID), INDEX ment_menu_ID (ment_menu_ID), INDEX ment_parent_ID (ment_parent_ID) diff --git a/inc/menus/model/_sitemenu.class.php b/inc/menus/model/_sitemenu.class.php index cf966debe41..b5536386f87 100644 --- a/inc/menus/model/_sitemenu.class.php +++ b/inc/menus/model/_sitemenu.class.php @@ -255,8 +255,8 @@ function duplicate() } // Copy all menu entries linked to the menu: - $menu_entry_fields = array( 'ment_ID', 'ment_menu_ID', 'ment_parent_ID', 'ment_order', 'ment_text', 'ment_type', - 'ment_coll_logo_size', 'ment_coll_ID', 'ment_item_ID', 'ment_url', 'ment_visibility', 'ment_highlight' ); + $menu_entry_fields = array( 'ment_ID', 'ment_menu_ID', 'ment_parent_ID', 'ment_order', 'ment_user_pic_size', 'ment_text', 'ment_type', + 'ment_coll_logo_size', 'ment_coll_ID', 'ment_item_ID', 'ment_url', 'ment_visibility', 'ment_access', 'ment_show_badge', 'ment_highlight', 'ment_class' ); $menu_entries_SQL = 'SELECT '.implode( ', ', $menu_entry_fields ).' FROM T_menus__entry diff --git a/inc/menus/model/_sitemenuentry.class.php b/inc/menus/model/_sitemenuentry.class.php index 9a6d992d7ea..86d5adda210 100644 --- a/inc/menus/model/_sitemenuentry.class.php +++ b/inc/menus/model/_sitemenuentry.class.php @@ -28,6 +28,7 @@ class SiteMenuEntry extends DataObject var $menu_ID; var $parent_ID; var $order; + var $user_pic_size; var $text; var $type; var $coll_logo_size; @@ -37,7 +38,17 @@ class SiteMenuEntry extends DataObject var $item_slug; var $url; var $visibility = 'always'; + var $access = 'perms'; + var $show_badge = 1; var $highlight = 1; + var $hide_empty = 0; + var $class; + + /** + * Error message if current User has no access to requested URL + * Useful when it is used from widget Menu + */ + var $url_error = NULL; /** * Collection @@ -76,6 +87,7 @@ function __construct( $db_row = NULL ) $this->menu_ID = $db_row->ment_menu_ID; $this->parent_ID = $db_row->ment_parent_ID; $this->order = $db_row->ment_order; + $this->user_pic_size = $db_row->ment_user_pic_size; $this->text = $db_row->ment_text; $this->type = $db_row->ment_type; $this->coll_logo_size = $db_row->ment_coll_logo_size; @@ -85,7 +97,11 @@ function __construct( $db_row = NULL ) $this->item_slug = $db_row->ment_item_slug; $this->url = $db_row->ment_url; $this->visibility = $db_row->ment_visibility; + $this->access = $db_row->ment_access; + $this->show_badge = $db_row->ment_show_badge; $this->highlight = $db_row->ment_highlight; + $this->hide_empty = $db_row->ment_hide_empty; + $this->class = $db_row->ment_class; } } @@ -123,6 +139,10 @@ function load_from_Request() param( 'ment_order', 'integer', NULL ); $this->set_from_Request( 'order', NULL, true ); + // Profile picture before text: + param( 'ment_user_pic_size', 'string' ); + $this->set_from_Request( 'user_pic_size' ); + // Text: param( 'ment_text', 'string' ); $this->set_from_Request( 'text' ); @@ -185,10 +205,25 @@ function load_from_Request() param( 'ment_visibility', 'string' ); $this->set_from_Request( 'visibility' ); + // Show to: + param( 'ment_access', 'string' ); + $this->set_from_Request( 'access' ); + + // Show badge: + param( 'ment_show_badge', 'integer', 0 ); + $this->set_from_Request( 'show_badge' ); + // Highlight: param( 'ment_highlight', 'integer', 0 ); $this->set_from_Request( 'highlight' ); + // Hide if empty: + param( 'ment_hide_empty', 'integer', 0 ); + $this->set_from_Request( 'hide_empty' ); + + // Extra CSS classes: + param( 'ment_class', 'string', NULL ); + $this->set_from_Request( 'class', NULL, true ); if( ! empty( $menu_Item_from_ID ) && ! empty( $menu_Item_from_slug ) && ( $menu_Item_from_ID->ID != $menu_Item_from_slug->ID ) ) { @@ -338,7 +373,7 @@ function & get_Item() */ function get_text( $force_default = false ) { - global $thumbnail_sizes; + global $thumbnail_sizes, $current_User; $entry_Blog = & $this->get_Blog(); @@ -429,7 +464,6 @@ function get_text( $force_default = false ) $text = T_('My visits'); if( is_logged_in() ) { - global $current_User; $text .= ' '.$current_User->get_profile_visitors_count().''; } break; @@ -475,30 +509,107 @@ function get_text( $force_default = false ) break; case 'myprofile': - $text = T_('My profile'); + $text = '$username$'; break; case 'admin': $text = T_('Admin').' »'; break; + case 'messages': + $text = T_('Messages'); + break; + + case 'contacts': + $text = T_('Contacts'); + break; + + case 'flagged': + $text = T_('Flagged Items'); + break; + default: $text = '[UNKNOWN]'; } } - $coll_logo_size = $this->get( 'coll_logo_size' ); - if( ! empty( $coll_logo_size ) && - isset( $thumbnail_sizes[ $coll_logo_size ] ) && - ( $coll_logo_File = $entry_Blog->get( 'collection_image' ) ) ) - { // Display collection logo before Menu text: + // Replace masks: + $text = preg_replace_callback( '#\$([a-z]+)\$#', array( $this, 'callback_text_mask' ), $text ); + + // Profile picture before text: + if( in_array( $this->get( 'type' ), array( 'logout', 'myprofile', 'visits', 'profile', 'avatar', 'useritems', 'usercomments' ) ) && + is_logged_in() && + ( $user_pic_size = $this->get( 'user_pic_size' ) ) && + isset( $thumbnail_sizes[ $user_pic_size ] ) ) + { + $text = $current_User->get_avatar_imgtag( $user_pic_size, 'avatar_before_login_middle' ).$text; + } + + // Collection logo before link text: + if( ! in_array( $this->get( 'type' ), array( 'item', 'admin', 'url', 'text' ) ) && + ( $coll_logo_size = $this->get( 'coll_logo_size' ) ) && + isset( $thumbnail_sizes[ $coll_logo_size ] ) && + ( $coll_logo_File = $entry_Blog->get( 'collection_image' ) ) ) + { $text = $coll_logo_File->get_thumb_imgtag( $coll_logo_size ).' '.$text; } + // Badge with count of unread messages or flagged items: + if( $this->get( 'show_badge' ) ) + { + switch( $this->get( 'type' ) ) + { + case 'messages': + // Show badge with count of uread messages: + $unread_messages_count = get_unread_messages_count(); + if( $unread_messages_count > 0 ) + { // If at least one unread message: + $text .= ' '.$unread_messages_count.''; + } + break; + + case 'flagged': + // Show badge with count of flagged items: + $flagged_items_count = $current_User->get_flagged_items_count( $entry_Blog->ID ); + if( $flagged_items_count > 0 ) + { // If at least one flagged item: + $text .= ' '.$flagged_items_count.''; + } + break; + } + } + return $text; } + /** + * Callback function to replace masks in menu text + * + * @param array Matches + * @return string Text with replaced masks to proper values + */ + function callback_text_mask( $m ) + { + global $current_User; + + switch( $m[0] ) + { + case '$username$': + return is_logged_in() + ? $current_User->get_colored_login( array( 'login_text' => 'name' ) ) + : '('.T_('anonymous').')'; + + case '$login$': + return is_logged_in() + ? $current_User->get_colored_login( array( 'login_text' => 'login' ) ) + : '('.T_('anonymous').')'; + } + + return $m[0]; + } + + /** * Get Menu Entry URL based on type * @@ -510,11 +621,13 @@ function get_url() if( empty( $entry_Blog ) ) { // We cannot use this menu entry without current collection: + $this->url_error = 'No Collection'; return false; } if( $this->get( 'visibility' ) == 'access' && ! $entry_Blog->has_access() ) { // Don't use this menu entry because current user has no access to the collection: + $this->url_error = 'No access'; return false; } @@ -524,6 +637,11 @@ function get_url() return $entry_Blog->get( 'url' ); case 'recentposts': + if( ! $entry_Blog->get_setting( 'postlist_enable' ) ) + { // This page is disabled: + $this->url_error = 'Disabled'; + return false; + } if( $entry_Chapter = & $this->get_Chapter() ) { // Use category url instead of default if the defined category is found in DB: return $entry_Chapter->get_permanent_url(); @@ -531,6 +649,11 @@ function get_url() return $entry_Blog->get( 'recentpostsurl' ); case 'search': + if( ! $entry_Blog->get_setting( 'search_enable' ) ) + { // This page is disabled: + $this->url_error = 'Disabled'; + return false; + } return $entry_Blog->get( 'searchurl' ); case 'arcdir': @@ -554,12 +677,13 @@ function get_url() case 'latestcomments': if( ! $entry_Blog->get_setting( 'comments_latest' ) ) { // This page is disabled: + $this->url_error = 'Disabled'; return false; } return $entry_Blog->get( 'lastcommentsurl' ); case 'owneruserinfo': - return url_add_param( $entry_Blog->get( 'userurl' ), 'user_ID='.$entry_Blog->owner_user_ID ); + return $entry_Blog->get( 'userurl', array( 'user_ID' => $entry_Blog->owner_user_ID ) ); case 'ownercontact': return $entry_Blog->get_contact_url(); @@ -567,6 +691,7 @@ function get_url() case 'login': if( is_logged_in() ) { // Don't display this link for already logged in users: + $this->url_error = 'Not logged in'; return false; } global $Settings; @@ -575,6 +700,7 @@ function get_url() case 'logout': if( ! is_logged_in() ) { // Current user must be logged in: + $this->url_error = 'Not logged in'; return false; } return get_user_logout_url( $entry_Blog->ID ); @@ -585,6 +711,7 @@ function get_url() case 'profile': if( ! is_logged_in() ) { // Current user must be logged in: + $this->url_error = 'Not logged in'; return false; } return get_user_profile_url( $entry_Blog->ID ); @@ -592,10 +719,35 @@ function get_url() case 'avatar': if( ! is_logged_in() ) { // Current user must be logged in: + $this->url_error = 'Not logged in'; return false; } return get_user_avatar_url( $entry_Blog->ID ); + case 'password': + if( ! is_logged_in() ) + { // Current user must be logged in: + $this->url_error = 'Not logged in'; + return false; + } + return get_user_pwdchange_url( $entry_Blog->ID ); + + case 'userprefs': + if( ! is_logged_in() ) + { // Current user must be logged in: + $this->url_error = 'Not logged in'; + return false; + } + return get_user_preferences_url( $entry_Blog->ID ); + + case 'usersubs': + if( ! is_logged_in() ) + { // Current user must be logged in: + $this->url_error = 'Not logged in'; + return false; + } + return get_user_subs_url( $entry_Blog->ID ); + case 'visits': global $Settings, $current_User; if( ! is_logged_in() || ! $Settings->get( 'enable_visit_tracking' ) ) @@ -673,17 +825,56 @@ function get_url() { // Don't show this link for not logged in users: return false; } - return $entry_Blog->get( 'userurl' ); + global $current_User; + return $entry_Blog->get( 'userurl', array( 'user_ID' => $current_User->ID, 'user_login' => $current_User->login ) ); break; case 'admin': - global $current_User; - if( ! ( is_logged_in() && $current_User->check_perm( 'admin', 'restricted' ) && $current_User->check_status( 'can_access_admin' ) ) ) + if( ! check_user_perm( 'admin', 'restricted' ) && check_user_status( 'can_access_admin' ) ) { // Don't allow admin url for users who have no access to backoffice: return false; } global $admin_url; return $admin_url; + + case 'messages': + case 'contacts': + switch( $this->get( 'access' ) ) + { + case 'loggedin': + if( ! is_logged_in() ) + { // User is not logged in: + $this->url_error = 'Not logged in'; + return false; + } + break; + case 'perms': + if( ! check_user_perm( 'perm_messaging', 'reply', false ) ) + { // User has no access for messaging: + $this->url_error = 'No access'; + return false; + } + break; + } + return $this->get( 'type' ) == 'messages' + // Messages: + ? $entry_Blog->get( 'threadsurl' ) + // Contacts: + : $entry_Blog->get( 'contactsurl' ); + + case 'flagged': + if( ! is_logged_in() ) + { // Only logged in user can flag items: + $this->url_error = 'Not logged in'; + return false; + } + global $current_User; + if( $this->get( 'hide_empty' ) && $current_User->get_flagged_items_count() == 0 ) + { // Hide this menu if current user has no flagged posts yet: + $this->url_error = 'No flagged posts'; + return false; + } + return $entry_Blog->get( 'flaggedurl' ); } return false; @@ -809,6 +1000,15 @@ function is_active() case 'admin': // This is never highlighted: return false; + + case 'messages': + return $disp == 'messages' || ( $disp == 'threads' && ( ! isset( $_GET['disp'] ) || $_GET['disp'] != 'msgform' ) ); + + case 'contacts': + return $disp == 'contacts'; + + case 'flagged': + return $disp == 'flagged'; } return false; diff --git a/inc/menus/views/_menu.form.php b/inc/menus/views/_menu.form.php index 7d8f1c75b3a..a5f93de0b05 100644 --- a/inc/menus/views/_menu.form.php +++ b/inc/menus/views/_menu.form.php @@ -108,7 +108,7 @@ } $buttons = array(); - if( $current_User->check_perm( 'options', 'edit' ) ) + if( check_user_perm( 'options', 'edit' ) ) { // Allow to save menu if current User has a permission: if( $action == 'copy' ) { @@ -142,7 +142,7 @@ */ function site_menu_entry_line( $SiteMenuEntry, $level ) { - global $line_class, $current_User, $Settings, $admin_url; + global $line_class, $Settings, $admin_url; global $SiteMenuEntryCache; global $Session; @@ -160,7 +160,7 @@ function site_menu_entry_line( $SiteMenuEntry, $level ) $r .= ''.$SiteMenuEntry->dget( 'order' ).''; // Name: - if( $current_User->check_perm( 'options', 'edit' ) ) + if( check_user_perm( 'options', 'edit' ) ) { // We have permission permission to edit: $edit_url = regenerate_url( 'action,ment_ID', 'ment_ID='.$SiteMenuEntry->ID.'&action=edit_entry' ); $r .= ' @@ -208,7 +208,7 @@ function site_menu_entry_line( $SiteMenuEntry, $level ) // Actions $r .= ''; - if( $current_User->check_perm( 'options', 'edit' ) ) + if( check_user_perm( 'options', 'edit' ) ) { // We have permission permission to edit, so display action column: $r .= action_icon( TB_('Edit...'), 'edit', $edit_url ); $r .= action_icon( TB_('New').'...', 'new', regenerate_url( 'action,ment_ID,blog', 'ment_parent_ID='.$SiteMenuEntry->ID.'&action=new_entry' ) ) @@ -285,7 +285,7 @@ function site_menu_entry_after_level( $level ) 'th' => TB_('Highlight'), 'th_class' => 'shrinkwrap', ); - if( $current_User->check_perm( 'options', 'edit' ) ) + if( check_user_perm( 'options', 'edit' ) ) { // We have permission to edit, so display action column: $Table->cols[] = array( 'th' => TB_('Actions'), diff --git a/inc/menus/views/_menu_entry.form.php b/inc/menus/views/_menu_entry.form.php index 5775060fafe..a931efefbce 100644 --- a/inc/menus/views/_menu_entry.form.php +++ b/inc/menus/views/_menu_entry.form.php @@ -15,7 +15,9 @@ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); -global $edited_SiteMenuEntry; +load_funcs( 'files/model/_image.funcs.php' ); + +global $edited_SiteMenuEntry, $admin_url; // Determine if we are creating or updating... global $action; @@ -40,14 +42,35 @@ $Form->text_input( 'ment_order', $edited_SiteMenuEntry->get( 'order' ), 11, TB_('Order'), '', array( 'maxlength' => 11 ) ); - $Form->text_input( 'ment_text', $edited_SiteMenuEntry->get( 'text' ), 50, TB_('Text'), ( $edited_SiteMenuEntry->get( 'type' ) != 'text' ? TB_('Leave empty for default').( $edited_SiteMenuEntry->ID > 0 ? ': '.$edited_SiteMenuEntry->get_text( true ).'' : '' ) : '' ), array( 'maxlength' => 128 ) ); - $Form->select_input_array( 'ment_type', $edited_SiteMenuEntry->get( 'type' ), get_site_menu_types(), TB_('Type') ); - load_funcs( 'files/model/_image.funcs.php' ); - $Form->select_input_array( 'ment_coll_logo_size', $edited_SiteMenuEntry->get( 'coll_logo_size' ), get_available_thumb_sizes( TB_('No logo') ), TB_('Collection logo before link text') ); + $Form->select_input_array( 'ment_coll_logo_size', $edited_SiteMenuEntry->get( 'coll_logo_size' ), get_available_thumb_sizes( TB_('No logo') ), TB_('Collection logo before link text'), NULL, array( + 'hide' => in_array( $edited_SiteMenuEntry->get( 'type' ), array( 'item', 'admin', 'url', 'text' ) ), + ) ); + + $Form->select_input_array( 'ment_user_pic_size', $edited_SiteMenuEntry->get( 'user_pic_size' ), get_available_thumb_sizes( TB_('No picture') ), TB_('Profile picture before text'), NULL, array( + 'hide' => ! in_array( $edited_SiteMenuEntry->get( 'type' ), array( 'logout', 'myprofile', 'visits', 'profile', 'avatar', 'useritems', 'usercomments' ) ), + ) ); + + $Form->text_input( 'ment_text', $edited_SiteMenuEntry->get( 'text' ), 50, TB_('Text'), ( $edited_SiteMenuEntry->get( 'type' ) != 'text' ? TB_('Leave empty for default').( $edited_SiteMenuEntry->ID > 0 ? ': '.$edited_SiteMenuEntry->get_text( true ).'' : '' ) : '' ), array( 'maxlength' => 128 ) ); - $Form->text_input( 'ment_coll_ID', $edited_SiteMenuEntry->get( 'coll_ID' ), 11, TB_('Collection ID'), '', array( 'maxlength' => 11, 'hide' => in_array( $edited_SiteMenuEntry->get( 'type' ), array( 'item', 'admin', 'url', 'text' ) ) ) ); + $Form->checkbox_input( 'ment_show_badge', $edited_SiteMenuEntry->get( 'show_badge' ), TB_('Show Badge'), array( + 'note' => TB_('Show a badge with count.'), + 'hide' => ! in_array( $edited_SiteMenuEntry->get( 'type' ), array( 'messages', 'flagged' ) ) + ) ); + + $msg_Blog = & get_setting_Blog( 'msg_blog_ID' ); + $coll_id_is_disabled = in_array( $edited_SiteMenuEntry->get( 'type' ), array( 'ownercontact', 'owneruserinfo', 'myprofile', 'profile', 'avatar', 'messages', 'contacts' ) ); + $Form->text_input( 'ment_coll_ID', $edited_SiteMenuEntry->get( 'coll_ID' ), 11, TB_('Collection ID'), '', array( + 'maxlength' => 11, + 'hide' => in_array( $edited_SiteMenuEntry->get( 'type' ), array( 'item', 'admin', 'url', 'text' ) ), + 'disabled' => $coll_id_is_disabled, + 'note' => T_( 'Leave empty for current collection.' ) + .( $msg_Blog ? ' ' : '' ), + ) ); $Form->text_input( 'ment_cat_ID', $edited_SiteMenuEntry->get( 'cat_ID' ), 11, TB_('Category ID'), '', array( 'maxlength' => 11, 'hide' => ! in_array( $edited_SiteMenuEntry->get( 'type' ), array( 'recentposts', 'postnew' ) ) ) ); @@ -57,11 +80,15 @@ $Form->text_input( 'ment_url', $edited_SiteMenuEntry->get( 'url' ), 128, TB_('URL'), '', array( 'maxlength' => 2000, 'hide' => ( $edited_SiteMenuEntry->get( 'type' ) != 'url' ) ) ); - $Form->radio( 'ment_visibility', $edited_SiteMenuEntry->get( 'visibility' ), + $Form->radio_input( 'ment_access', $edited_SiteMenuEntry->get( 'access' ), array( - array( 'always', TB_( 'Always show') ), - array( 'access', TB_( 'Only show if access is allowed' ) ) - ), TB_('Visibility'), true ); + array( 'value' => 'any', 'label' => TB_('All users') ), + array( 'value' => 'loggedin', 'label' => TB_('Logged in users') ), + array( 'value' => 'perms', 'label' => TB_('Users with permissions only') ), + ), TB_('Show to'), array( + 'lines' => true, + 'hide' => ! in_array( $edited_SiteMenuEntry->get( 'type' ), array( 'messages', 'contacts' ) ) + ) ); $Form->radio( 'ment_highlight', $edited_SiteMenuEntry->get( 'highlight' ), array( @@ -69,8 +96,21 @@ array( 0, TB_('Do not try to highlight') ) ), TB_('Highlight'), true ); + $Form->text_input( 'ment_class', $edited_SiteMenuEntry->get( 'class' ), 50, TB_('Extra CSS classes'), '', array( 'maxlength' => 128 ) ); + + $Form->checkbox_input( 'ment_hide_empty', $edited_SiteMenuEntry->get( 'hide_empty' ), TB_('Hide if empty'), array( + 'note' => TB_('Check to hide this menu if the list is empty.'), + 'hide' => $edited_SiteMenuEntry->get( 'type' ) != 'flagged', + ) ); + + $Form->radio( 'ment_visibility', $edited_SiteMenuEntry->get( 'visibility' ), + array( + array( 'always', TB_( 'Always show') ), + array( 'access', TB_( 'Only show if access is allowed' ) ) + ), TB_('Visibility'), true ); + $buttons = array(); - if( $current_User->check_perm( 'options', 'edit' ) ) + if( check_user_perm( 'options', 'edit' ) ) { // Allow to save menu if current User has a permission: $buttons[] = array( 'submit', 'submit', ( $creating ? TB_('Record') : TB_('Save Changes!') ), 'SaveButton' ); } @@ -82,8 +122,32 @@ jQuery( '#ment_type' ).change( function() { var link_type_value = jQuery( this ).val(); + // Hide/Show Profile picture size: + jQuery( '#ffield_ment_user_pic_size' ).toggle( link_type_value == 'logout' || + link_type_value == 'myprofile' || + link_type_value == 'visits' || + link_type_value == 'profile' || + link_type_value == 'avatar' || + link_type_value == 'useritems' || + link_type_value == 'usercomments' ); + if( link_type_value == 'myprofile' && jQuery( '#ment_user_pic_size' ).val() == '' ) + { // Set default picture size for "View my profile": + jQuery( '#ment_user_pic_size' ).val( 'crop-top-15x15' ); + } // Hide/Show collection ID: - jQuery( '#ffield_ment_coll_ID' ).toggle( link_type_value != 'item' && link_type_value != 'admin' && link_type_value != 'url' && link_type_value != 'text' ); + jQuery( '#ffield_ment_coll_ID, #ffield_ment_coll_logo_size' ).toggle( link_type_value != 'item' && link_type_value != 'admin' && link_type_value != 'url' && link_type_value != 'text' ); + if( jQuery( '.evo_setting_coll_disabled' ).length ) + { // Hide/Show info for disabled collection: + var coll_disabled = link_type_value == 'ownercontact' || + link_type_value == 'owneruserinfo' || + link_type_value == 'myprofile' || + link_type_value == 'profile' || + link_type_value == 'avatar' || + link_type_value == 'messages' || + link_type_value == 'contacts'; + jQuery( '.evo_setting_coll_disabled' ).toggle( coll_disabled ); + jQuery( '#ment_coll_ID' ).prop( 'disabled', coll_disabled ); + } // Hide/Show category ID: jQuery( '#ffield_ment_cat_ID' ).toggle( link_type_value == 'recentposts' || link_type_value == 'postnew' ); // Hide/Show item ID: @@ -91,5 +155,11 @@ jQuery( '#ffield_ment_item_slug' ).toggle( link_type_value == 'item' ); // Hide/Show URL: jQuery( '#ffield_ment_url' ).toggle( link_type_value == 'url' ); + // Hide/Show setting "Show to": + jQuery( '#ffield_ment_access' ).toggle( link_type_value == 'messages' || link_type_value == 'contacts' ); + // Hide/Show setting "Show Badge": + jQuery( '#ffield_ment_show_badge' ).toggle( link_type_value == 'messages' || link_type_value == 'flagged' ); + // Hide/Show setting "Hide if empty": + jQuery( '#ffield_ment_hide_empty' ).toggle( link_type_value == 'flagged' ); } ); diff --git a/inc/menus/views/_menus.view.php b/inc/menus/views/_menus.view.php index 1c772358029..c977b25233c 100644 --- a/inc/menus/views/_menus.view.php +++ b/inc/menus/views/_menus.view.php @@ -46,7 +46,7 @@ 'td_class' => 'nowrap', ); -if( $current_User->check_perm( 'options', 'edit' ) ) +if( check_user_perm( 'options', 'edit' ) ) { $Results->cols[] = array( 'th' => T_('Actions'), diff --git a/inc/messaging/_messaging.init.php b/inc/messaging/_messaging.init.php index 70a18a6007c..1e18f9a7733 100644 --- a/inc/messaging/_messaging.init.php +++ b/inc/messaging/_messaging.init.php @@ -310,12 +310,11 @@ function build_evobar_menu() global $DB; global $topleft_Menu, $topright_Menu; global $admin_url; - global $current_User; $left_entries = array(); $right_entries = array(); - if( $current_User->check_perm( 'perm_messaging', 'reply' ) ) + if( check_user_perm( 'perm_messaging', 'reply' ) ) { if( ! empty( $topleft_Menu->_menus['entries']['site']['entries'] ) ) { @@ -370,22 +369,18 @@ function build_evobar_menu() function build_menu_3() { global $admin_url; - /** - * @var User - */ - global $current_User; /** * @var AdminUI_general */ global $AdminUI; - if( !$current_User->check_perm( 'admin', 'restricted' ) ) + if( ! check_user_perm( 'admin', 'restricted' ) ) { return; } - if( $current_User->check_perm( 'perm_messaging', 'reply' ) ) + if( check_user_perm( 'perm_messaging', 'reply' ) ) { // Permission to view messaging: // Count unread messages for current user @@ -453,7 +448,7 @@ function handle_htsrv_action() } // Check permission: - $current_User->check_perm( 'perm_messaging', 'reply', true ); + check_user_perm( 'perm_messaging', 'reply', true ); // set where to redirect $redirect_to = param( 'redirect_to', 'url', NULL ); @@ -526,7 +521,7 @@ function handle_htsrv_action() case 'delete': // delete thread // Check permission: - $current_User->check_perm( 'perm_messaging', 'delete', true ); + check_user_perm( 'perm_messaging', 'delete', true ); $confirmed = param( 'confirmed', 'integer', 0 ); if( $confirmed ) @@ -626,7 +621,7 @@ function handle_htsrv_action() case 'delete': // delete message // Check permission: - $current_User->check_perm( 'perm_messaging', 'delete', true ); + check_user_perm( 'perm_messaging', 'delete', true ); $msg_ID = param( 'msg_ID', 'integer', true ); $MessageCache = & get_MessageCache(); diff --git a/inc/messaging/abuse.ctrl.php b/inc/messaging/abuse.ctrl.php index d50fd662aa8..d703515c618 100644 --- a/inc/messaging/abuse.ctrl.php +++ b/inc/messaging/abuse.ctrl.php @@ -6,13 +6,8 @@ load_class( 'messaging/model/_thread.class.php', 'Thread' ); load_class( 'messaging/model/_message.class.php', 'Message' ); -/** - * @var User - */ -global $current_User; - // Check minimum permission: -if( !$current_User->check_perm( 'perm_messaging', 'abuse' ) ) +if( ! check_user_perm( 'perm_messaging', 'abuse' ) ) { $Messages->add( 'Sorry, you are not allowed to abuse management!' ); header_redirect( $admin_url ); @@ -50,7 +45,7 @@ $Session->assert_received_crumb( 'messaging_threads' ); // Check permission: - $current_User->check_perm( 'perm_messaging', 'delete', true ); + check_user_perm( 'perm_messaging', 'delete', true ); // Make sure we got an thrd_ID: param( 'thrd_ID', 'integer', true ); diff --git a/inc/messaging/contacts.ctrl.php b/inc/messaging/contacts.ctrl.php index 450d91593a1..7f6ff49451c 100644 --- a/inc/messaging/contacts.ctrl.php +++ b/inc/messaging/contacts.ctrl.php @@ -14,13 +14,10 @@ */ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); -/** - * @var User - */ -global $DB, $current_User; +global $DB; // Check minimum permission: -if( !$current_User->check_perm( 'perm_messaging', 'reply' ) ) +if( ! check_user_perm( 'perm_messaging', 'reply' ) ) { $Messages->add( 'Sorry, you are not allowed to view cotnacts!' ); header_redirect( $admin_url ); diff --git a/inc/messaging/messages.ctrl.php b/inc/messaging/messages.ctrl.php index 0de1f2eef0c..7799db600b9 100644 --- a/inc/messaging/messages.ctrl.php +++ b/inc/messaging/messages.ctrl.php @@ -26,7 +26,7 @@ global $current_User; // Check minimum permission: -if( !$current_User->check_perm( 'perm_messaging', 'reply' ) ) +if( ! check_user_perm( 'perm_messaging', 'reply' ) ) { $Messages->add( TB_('You are not allowed to view messages.') ); header_redirect( $admin_url ); @@ -41,7 +41,7 @@ global $perm_abuse_management; $tab = param( 'tab', 'string' ); -if( $tab == 'abuse' && $current_User->check_perm( 'perm_messaging', 'abuse' ) ) +if( $tab == 'abuse' && check_user_perm( 'perm_messaging', 'abuse' ) ) { // We go from abuse management and have a permissions $perm_abuse_management = true; } @@ -139,7 +139,7 @@ $Session->assert_received_crumb( 'messaging_messages' ); // Check permission: - $current_User->check_perm( 'perm_messaging', 'delete', true ); + check_user_perm( 'perm_messaging', 'delete', true ); // Make sure we got an msg_ID: param( 'msg_ID', 'integer', true ); @@ -198,8 +198,6 @@ // Require colorbox js: require_js_helper( 'colorbox' ); -// Init JS to quick upload several files: -init_fileuploader_js(); // Display messages depending on user email status display_user_email_status_message(); diff --git a/inc/messaging/model/_message.class.php b/inc/messaging/model/_message.class.php index bdad9b53e08..07e569a958f 100644 --- a/inc/messaging/model/_message.class.php +++ b/inc/messaging/model/_message.class.php @@ -775,7 +775,7 @@ function check_perm( $action, $assert = true ) { global $current_User; - return $current_User->check_perm( 'perm_messaging', $action, $assert ); + return check_user_perm( 'perm_messaging', $action, $assert ); } @@ -1095,7 +1095,7 @@ function get_images( $params = array(), $format = 'htmlbody' ) 'gallery_colls' => 5, 'gallery_order' => '', // 'ASC', 'DESC', 'RAND' 'gallery_link_rel' => 'lightbox[m'.$this->ID.']', - 'restrict_to_image_position' => 'inline', // 'teaser'|'teaserperm'|'teaserlink'|'aftermore'|'inline'|'cover' + 'restrict_to_image_position' => 'inline', // 'teaser'|'teaserperm'|'teaserlink'|'aftermore'|'inline'|'cover'|'background' 'exclude_inline_tagged' => true, // Use true to exclude inline attachments which are already rendered in content by inline tags like '[image:123]' 'data' => & $r, 'get_rendered_attachments' => true, @@ -1248,7 +1248,7 @@ function get_files( $params = array(), $format = 'htmlbody' ) // sam2kb> It's needed only for flexibility, in the meantime if user attaches 200 files he expects to see all of them in skin, I think. 'limit_attach' => 1000, // Max # of files displayed 'limit' => 1000, - // Optionally restrict to files/images linked to specific position: 'teaser'|'teaserperm'|'teaserlink'|'aftermore'|'inline'|'cover' + // Optionally restrict to files/images linked to specific position: 'teaser'|'teaserperm'|'teaserlink'|'aftermore'|'inline'|'cover'|'background' 'restrict_to_image_position' => 'inline', 'exclude_inline_tagged' => true, // Use true to exclude inline attachments which are already rendered in content by inline tags like '[image:123]' 'data' => '', diff --git a/inc/messaging/model/_messaging.funcs.php b/inc/messaging/model/_messaging.funcs.php index 4d0afb11e47..f5c343851ba 100644 --- a/inc/messaging/model/_messaging.funcs.php +++ b/inc/messaging/model/_messaging.funcs.php @@ -62,7 +62,7 @@ function check_blocked_contacts( $recipients_list ) return NULL; } - if( $current_User->check_perm( 'perm_messaging', 'delete' ) ) + if( check_user_perm( 'perm_messaging', 'delete' ) ) { // user with delete messaging permission are allowed to send private messages to anyone who has access to read them. return NULL; } @@ -71,7 +71,7 @@ function check_blocked_contacts( $recipients_list ) $SQL->SELECT( 'u.user_login' ); - if( $current_User->check_perm( 'perm_messaging', 'write', false ) ) + if( check_user_perm( 'perm_messaging', 'write', false ) ) { // get blocked contacts for user with write permission $sub_SQL = new SQL(); @@ -153,7 +153,7 @@ function set_contact_blocked( $user_ID, $blocked ) */ function create_new_thread() { - global $Settings, $current_User, $Messages, $edited_Thread, $edited_Message, $action, $Plugins; + global $Settings, $Messages, $edited_Thread, $edited_Message, $action, $Plugins; // Insert new thread: $edited_Thread = new Thread(); @@ -161,7 +161,7 @@ function create_new_thread() $edited_Message->Thread = & $edited_Thread; // Check permission: - $current_User->check_perm( 'perm_messaging', 'reply', true ); + check_user_perm( 'perm_messaging', 'reply', true ); if( $Settings->get('system_lock') ) { // System is locked for maintenance, All users cannot send a message @@ -224,14 +224,14 @@ function create_new_thread() */ function create_new_message( $thrd_ID ) { - global $Settings, $current_User, $Messages, $edited_Message, $action, $Plugins; + global $Settings, $Messages, $edited_Message, $action, $Plugins; // Insert new message: $edited_Message = new Message(); $edited_Message->thread_ID = $thrd_ID; // Check permission: - $current_User->check_perm( 'perm_messaging', 'reply', true ); + check_user_perm( 'perm_messaging', 'reply', true ); if( $Settings->get('system_lock') ) { // System is locked for maintenance, All users cannot send a message @@ -386,7 +386,7 @@ function get_messages_link_to( $thread_ID = NULL, $user_ID = NULL ) */ function get_messaging_sub_entries( $is_admin ) { - global $Collection, $Blog, $current_User; + global $Collection, $Blog; if( $is_admin ) { @@ -406,7 +406,7 @@ function get_messaging_sub_entries( $is_admin ) 'href' => $url.'contacts' ), ); - if( $is_admin && $current_User->check_perm( 'options', 'edit' ) ) + if( $is_admin && check_user_perm( 'options', 'edit' ) ) { $messaging_sub_entries[ 'msgsettings' ] = array( 'text' => T_('Settings'), @@ -427,7 +427,7 @@ function get_messaging_sub_entries( $is_admin ) ), ); } - if( $current_User->check_perm( 'perm_messaging', 'abuse' ) ) + if( check_user_perm( 'perm_messaging', 'abuse' ) ) { $messaging_sub_entries[ 'abuse' ] = array( 'text' => T_('Abuse Management'), @@ -1989,8 +1989,7 @@ function threads_results_block( $params = array() ) return; } - global $current_User; - if( !$current_User->check_perm( 'users', 'moderate' ) || !$current_User->check_perm( 'perm_messaging', 'reply' ) ) + if( ! check_user_perm( 'users', 'moderate' ) || ! check_user_perm( 'perm_messaging', 'reply' ) ) { // Check minimum permission: return; } @@ -2010,7 +2009,7 @@ function threads_results_block( $params = array() ) } } - global $DB, $current_User, $AdminUI; + global $DB, $AdminUI; param( 'user_tab', 'string', '', true ); param( 'user_ID', 'integer', 0, true ); @@ -2022,7 +2021,7 @@ function threads_results_block( $params = array() ) ); // Check permission: - if( $current_User->check_perm( 'perm_messaging', 'abuse' ) ) + if( check_user_perm( 'perm_messaging', 'abuse' ) ) { // Create result set: $threads_user_filter = ( $params['messages_type'] == 'received' ? 'received_user_ID' : 'sent_user_ID' ); @@ -2107,8 +2106,6 @@ function received_threads_results_block( $params = array() ) */ function threads_results( & $threads_Results, $params = array() ) { - global $current_User; - // Make sure we are not missing any param: $params = array_merge( array( 'abuse_management' => 0, // 1 - abuse management mode @@ -2163,7 +2160,7 @@ function threads_results( & $threads_Results, $params = array() ) if( $params['display_actions'] ) { // Display Actions column - if( $current_User->check_perm( 'perm_messaging', 'delete' ) ) + if( check_user_perm( 'perm_messaging', 'delete' ) ) { // We have permission to modify: $threads_Results->cols[] = array( 'th' => T_('Del'), diff --git a/inc/messaging/model/_thread.class.php b/inc/messaging/model/_thread.class.php index bde418af0e7..793262e1317 100644 --- a/inc/messaging/model/_thread.class.php +++ b/inc/messaging/model/_thread.class.php @@ -290,7 +290,7 @@ function param_check__recipients( $var, $recipients, $recipients_array ) $recipients_from_different_country = array(); $recipients_restricted_pm = array(); // check if recipient user enable private messages only if sender user doesn't have 'delete' messaging permission - $check_enable_pm = !$current_User->check_perm( 'perm_messaging', 'delete' ); + $check_enable_pm = ! check_user_perm( 'perm_messaging', 'delete' ); $cross_country_restrict = has_cross_country_restriction( 'contact' ); foreach( $recipients_list as $recipient ) { @@ -493,9 +493,7 @@ function load_recipients() */ function check_perm( $action, $assert = true ) { - global $current_User; - - return $current_User->check_perm( 'perm_messaging', $action, $assert ); + return check_user_perm( 'perm_messaging', $action, $assert ); } @@ -557,7 +555,7 @@ function check_allow_reply() return false; } - if( $current_User->check_perm( 'perm_messaging', 'delete' ) ) + if( check_user_perm( 'perm_messaging', 'delete' ) ) { // users with delete permission are always able to reply to a conversation where they are involved return true; } diff --git a/inc/messaging/msg_settings.ctrl.php b/inc/messaging/msg_settings.ctrl.php index 3f635636e35..c2d22984044 100644 --- a/inc/messaging/msg_settings.ctrl.php +++ b/inc/messaging/msg_settings.ctrl.php @@ -20,7 +20,7 @@ global $DB, $current_User, $Settings; // Check minimum permission: -$current_User->check_perm( 'options', 'edit', true ); +check_user_perm( 'options', 'edit', true ); // Selected tab: $tab = param( 'tab', 'string', 'general' ); diff --git a/inc/messaging/threads.ctrl.php b/inc/messaging/threads.ctrl.php index d8d748c674c..8d1c84bc79d 100644 --- a/inc/messaging/threads.ctrl.php +++ b/inc/messaging/threads.ctrl.php @@ -12,7 +12,7 @@ global $current_User; // Check minimum permission: -if( !$current_User->check_perm( 'perm_messaging', 'reply' ) ) +if( ! check_user_perm( 'perm_messaging', 'reply' ) ) { $Messages->add( 'Sorry, you are not allowed to view threads!' ); header_redirect( $admin_url ); @@ -127,7 +127,7 @@ case 'delete': // Delete thread: // Check permission: - $current_User->check_perm( 'perm_messaging', 'delete', true ); + check_user_perm( 'perm_messaging', 'delete', true ); if( param( 'confirm', 'integer', 0 ) ) { // confirmed, Delete from DB: @@ -191,8 +191,6 @@ // Require colorbox js: require_js_helper( 'colorbox' ); - // Init JS to quick upload several files: - init_fileuploader_js(); break; default: $AdminUI->set_page_manual_link( 'conversations-list' ); diff --git a/inc/messaging/views/_contact_list.view.php b/inc/messaging/views/_contact_list.view.php index d04723e32b1..a8358cda5c2 100644 --- a/inc/messaging/views/_contact_list.view.php +++ b/inc/messaging/views/_contact_list.view.php @@ -488,45 +488,9 @@ function contacts_groups( $user_ID ) $Form->end_form(); $Form->switch_layout( NULL ); -?> - - \ No newline at end of file +?> diff --git a/inc/messaging/views/_message_list.view.php b/inc/messaging/views/_message_list.view.php index bb2cedb1a91..3ebe83fd0be 100644 --- a/inc/messaging/views/_message_list.view.php +++ b/inc/messaging/views/_message_list.view.php @@ -226,7 +226,7 @@ function filter_messages( & $Form ) /** * Actions: */ -if( $current_User->check_perm( 'perm_messaging', 'delete' ) && ( $Results->get_total_rows() > 1 ) && ( $action != 'preview' ) ) +if( check_user_perm( 'perm_messaging', 'delete' ) && ( $Results->get_total_rows() > 1 ) && ( $action != 'preview' ) ) { // We have permission to modify and there are more than 1 message (otherwise it's better to delete the whole thread): $Results->cols[] = array( 'th' => T_('Del'), @@ -313,7 +313,7 @@ function filter_messages( & $Form ) 'form_use_fieldset' => false, ) ); - if( $current_User->check_perm( 'files', 'view' ) ) + if( check_user_perm( 'files', 'view' ) ) { // If current user has a permission to view the files: load_class( 'links/model/_linkmessage.class.php', 'LinkMessage' ); // Initialize this object as global because this is used in many link functions: diff --git a/inc/messaging/views/_thread.form.php b/inc/messaging/views/_thread.form.php index 647590778d8..30b6a443e4f 100644 --- a/inc/messaging/views/_thread.form.php +++ b/inc/messaging/views/_thread.form.php @@ -114,7 +114,7 @@ 'form_use_fieldset' => false, ) ); -if( is_admin_page() && $current_User->check_perm( 'files', 'view' ) ) +if( is_admin_page() && check_user_perm( 'files', 'view' ) ) { // If current user has a permission to view the files AND it is back-office: load_class( 'links/model/_linkmessage.class.php', 'LinkMessage' ); // Initialize this object as global because this is used in many link functions: @@ -201,107 +201,29 @@ if( $params['allow_select_recipients'] ) { // User can select recipients -?> - -recipients_list ) ) { $recipients_list = $edited_Thread->recipients_list; @@ -336,7 +258,7 @@ function check_form_thread() $Results->Cache = & get_MessageCache(); if( $creating_success ) - { // Display error messages again before preview of message + { // Display error messages again before preview of message global $Messages; $Messages->display(); } @@ -376,4 +298,4 @@ function check_form_thread() echo $params['messages_list_end']; } // ------------------ PREVIEW MESSAGE END ------------------ // -?> \ No newline at end of file +?> diff --git a/inc/messaging/views/_thread_list.view.php b/inc/messaging/views/_thread_list.view.php index 07d57d5001e..16be76b1dfc 100644 --- a/inc/messaging/views/_thread_list.view.php +++ b/inc/messaging/views/_thread_list.view.php @@ -14,7 +14,6 @@ */ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); -global $current_User; global $DB, $Collection, $Blog; global $perm_abuse_management; // TRUE if we go from Abuse Management diff --git a/inc/plugins/_plugin.class.php b/inc/plugins/_plugin.class.php index fb764e3adce..06693392b00 100644 --- a/inc/plugins/_plugin.class.php +++ b/inc/plugins/_plugin.class.php @@ -1055,6 +1055,7 @@ function AdminAfterEvobarInit() * to modify it. * * This is the hook to register menu entries. See {@link register_menu_entry()}. + * Remember to set adminUI_set_path() function to set the correct full selected path. */ function AdminAfterMenuInit() { @@ -3940,9 +3941,9 @@ function get_README_link() */ function get_help_file() { - global $default_locale, $plugins_path, $current_User; + global $default_locale, $plugins_path; - if( empty( $current_User ) || !$current_User->check_perm( 'options', 'view', false ) ) + if( ! check_user_perm( 'options', 'view' ) ) { // README gets displayed through plugins controller, which requires these perms // TODO: Catch "disp_help" and "disp_help_plain" messages in plugins.php before general perms check!? return false; @@ -3996,9 +3997,9 @@ function get_edit_settings_link() */ function get_edit_settings_url() { - global $current_User, $admin_url; + global $admin_url; - if( ! $current_User->check_perm( 'options', 'edit', false ) ) + if( ! check_user_perm( 'options', 'edit', false ) ) { return false; } @@ -4070,6 +4071,27 @@ function get_widget_icon() } + /** + * Display widget title + * + * @param string Title, NULL to use title from widget param 'title' + */ + function display_widget_title( $widget_title = NULL ) + { + if( $widget_title === NULL ) + { // Use title from widget param: + $widget_title = $this->get_widget_setting( 'title' ); + } + + if( ! empty( $widget_title ) ) + { // We want to display a title for the widget block: + echo $this->widget_params['block_title_start']; + echo $widget_title; + echo $this->widget_params['block_title_end']; + } + } + + /** * Display widget debug message e-g on designer mode when we need to show widget when nothing to display currently * @@ -4710,12 +4732,28 @@ function GetInsertImageInlineTagJavaScript( & $params ) * this function is used to add unique version number for each plugin * * @param string Name of CSS file relative to current plugin folder - * @param boolean TRUE to print style tag on the page, FALSE to store in array to print then inside + * @param boolean TRUE to print style tag on the page, FALSE to store in array to print then inside or + * @param string Position where the CSS files will be inserted, either 'headlines' (inside ) or 'footerlines' (before ) + * @param boolean TRUE to load CSS file asynchronously, FALSE otherwise. + */ + function require_css( $css_file, $output = false, $position = 'headlines', $async = false ) + { + global $app_version_long; + require_css( $this->get_plugin_url().$css_file, 'absolute', NULL, NULL, $this->version.'+'.$app_version_long, $output, $position, $async ); + } + + + /** + * Require CSS file to load asynchronously + * + * @param string Name of CSS file relative to current plugin folder + * @param boolean TRUE to print style tag on the page, FALSE to store in array to print then inside or + * @param string Position where the CSS files will be inserted, either 'headlines' (inside ) or 'footerlines' (before ) */ - function require_css( $css_file, $output = false ) + function require_css_async( $css_file, $output = false, $position = 'headlines' ) { global $app_version_long; - require_css( $this->get_plugin_url().$css_file, 'relative', NULL, NULL, $this->version.'+'.$app_version_long, $output ); + require_css( $this->get_plugin_url().$css_file, 'absolute', NULL, NULL, $this->version.'+'.$app_version_long, $output, $position, true ); } @@ -4726,11 +4764,41 @@ function require_css( $css_file, $output = false ) * * @param string Name of JavaScript file relative to plugin folder * @param boolean TRUE to print script tag on the page, FALSE to store in array to print then inside + * @param boolean 'async' or TRUE to add attribute "async" to load javascript asynchronously, + * 'defer' to add attribute "defer" asynchronously in the order they occur in the page, + * 'immediate' or FALSE to load javascript immediately + * @param string Position where the JS file will be inserted, either 'headlines' (inside ) or 'footerlines' (before ) */ - function require_js( $js_file, $output = false ) + function require_js( $js_file, $output = false, $async_defer = false, $position = 'headlines' ) { global $app_version_long; - require_js( $this->get_plugin_url().$js_file, 'relative', false, $output, $this->version.'+'.$app_version_long ); + require_js( $this->get_plugin_url().$js_file, 'absolute', $async_defer, $output, $this->version.'+'.$app_version_long, $position ); + } + + + /** + * Require javascript file to load asynchronously with attribute "async" + * + * @param string Name of JavaScript file relative to plugin folder + * @param boolean TRUE to print script tag on the page, FALSE to store in array to print then inside + * @param string Position where the JS file will be inserted, either 'headlines' (inside ) or 'footerlines' (before ) + */ + function require_js_async( $js_file, $output = false, $position = 'headlines' ) + { + $this->require_js( $js_file, $output, 'async', $position ); + } + + + /** + * Require javascript file to load asynchronously with attribute "defer" in the order they occur in the page + * + * @param string Name of JavaScript file relative to plugin folder + * @param boolean TRUE to print script tag on the page, FALSE to store in array to print then inside + * @param string Position where the JS file will be inserted, either 'headlines' (inside ) or 'footerlines' (before ) + */ + function require_js_defer( $js_file, $output = false, $position = 'headlines' ) + { + $this->require_js( $js_file, $output, 'defer', $position ); } diff --git a/inc/plugins/_plugin.funcs.php b/inc/plugins/_plugin.funcs.php index b9e4f2027cb..94332efcf5a 100644 --- a/inc/plugins/_plugin.funcs.php +++ b/inc/plugins/_plugin.funcs.php @@ -326,6 +326,11 @@ function autoform_display_field( $parname, $parmeta, & $Form, $set_type, $Obj, $ $original_form_fieldstart_checkbox = $Form->fieldstart_checkbox; $Form->fieldstart_checkbox = preg_replace( '/>$/', 'style="display:none">', $Form->fieldstart_checkbox ); } + if( isset( $Form->fieldstart_radio ) ) + { + $original_form_fieldstart_radio = $Form->fieldstart_radio; + $Form->fieldstart_radio = preg_replace( '/>$/', 'style="display:none">', $Form->fieldstart_radio ); + } } switch( $parmeta['type'] ) @@ -732,6 +737,9 @@ function( r, status ) } break; + case 'item_selector': + $Form->item_selector( $input_name, $set_value, $set_label, $parmeta ); + break; default: debug_die( 'Unsupported type ['.$parmeta['type'].'] from GetDefaultSettings()!' ); @@ -745,6 +753,10 @@ function( r, status ) { // Revert original field start html code: $Form->fieldstart_checkbox = $original_form_fieldstart_checkbox; } + if( isset( $original_form_fieldstart_radio ) ) + { // Revert original field start html code: + $Form->fieldstart_radio = $original_form_fieldstart_radio; + } if( $outer_most && $has_array_type ) { // Note for Non-Javascript users: diff --git a/inc/plugins/model/_plugins.class.php b/inc/plugins/model/_plugins.class.php index c13969f081c..decf438d854 100644 --- a/inc/plugins/model/_plugins.class.php +++ b/inc/plugins/model/_plugins.class.php @@ -334,7 +334,7 @@ function & register( $classname, $ID = 0, $priority = -1, $classfile_path = NULL if( ! empty( $this->log_register ) ) { // Display additional log on upgrade page when we reload all plugins: global $plugins_path; - echo '- Reloading "'.$classname.'" from '.substr( $classfile_path, strlen( $plugins_path ) ).'
    '; + echo get_install_format_text_and_log( '- Reloading "'.$classname.'" from '.substr( $classfile_path, strlen( $plugins_path ) ).'
    ' ); evo_flush(); } @@ -674,7 +674,7 @@ function init_settings( & $Plugin ) */ function instantiate_Settings( & $Plugin, $set_type ) { - global $Debuglog, $Timer; + global $Debuglog, $Timer, $Blog; $Timer->resume( 'plugins_inst_'.$set_type ); @@ -705,8 +705,11 @@ function instantiate_Settings( & $Plugin, $set_type ) // Check what other settings are defined for the Plugin, // We should not merge them with $defaults because they are stored in different DB table, // I.e. they are should be initialized in $Plugin->Settings, but we still need this object for a proper settings work: - $other_defaults = $Plugin->get_coll_setting_definitions( $params ); - $other_defaults = array_merge( $other_defaults, $Plugin->get_widget_param_definitions( $params ) ); + if( isset( $Blog ) ) + { // Only when current collection is defined in order to avoid errors because global $Blog may be used inside: + $other_defaults = $Plugin->get_coll_setting_definitions( $params ); + $other_defaults = array_merge( $other_defaults, $Plugin->get_widget_param_definitions( $params ) ); + } } if( empty( $defaults ) && empty( $other_defaults ) ) @@ -1342,7 +1345,7 @@ function call_by_code( $code, $params = array() ) /** - * Render the content of an item by calling the relevant renderer plugins. + * Render the content of an item, Comment, Message, Widget by calling the relevant renderer plugins. * * @param string content to render (by reference) * @param array renderer codes to use for opt-out, opt-in and lazy @@ -1350,12 +1353,11 @@ function call_by_code( $code, $params = array() ) * 'entityencoded', 'xml', 'htmlfeed' and 'text' are supported. * @param array Additional params to the Render* methods (e.g. "Item" for items). * Do not use "data" or "format" here, because it gets used internally. + * @param string Prefix of render function: 'Render' - for rendering at save in DB time, 'Display' - for rendering at display on screen time * @return string rendered content */ function render( & $content, $renderers, $format, $params, $event_prefix = 'Render' ) { - // echo implode(',',$renderers); - $params['data'] = & $content; $params['format'] = $format; @@ -1407,10 +1409,16 @@ function render( & $content, $renderers, $format, $params, $event_prefix = 'Rend $setting_Blog = & get_setting_Blog( 'default_blog_ID' ); } + // Collect all renderer plugins used in current page in order to know when we really need to load their JS/CSS files: + global $evo_renderers_used_in_current_page; + if( ! is_array( $evo_renderers_used_in_current_page ) ) + { // Initialize array for curently used renderer plugins once: + $evo_renderers_used_in_current_page = array(); + } + $evo_renderers_used_in_current_page += $renderers; + foreach( $renderer_Plugins as $loop_RendererPlugin ) { // Go through whole list of renders - // echo ' ',$loop_RendererPlugin->code, ':'; - $apply_rendering_value = $loop_RendererPlugin->get_coll_setting( 'coll_apply_rendering', $setting_Blog ); if( $loop_RendererPlugin->is_renderer_enabled( $apply_rendering_value, $renderers ) ) { // Plugin is enabled to call method @@ -2391,28 +2399,27 @@ function get_renderer_checkboxes( $current_renderers = NULL, $params ) { if( is_admin_page() ) { // Display info about no renderer plugins only in backoffice - global $current_User; - if( is_logged_in() && $current_User->check_perm( 'admin', 'normal' ) ) + if( check_user_perm( 'admin', 'normal' ) ) { global $admin_url; switch( $setting_name ) { case 'msg_apply_rendering': - if( $current_User->check_perm( 'perm_messaging', 'reply' ) && $current_User->check_perm( 'options', 'edit' ) ) + if( check_user_perm( 'perm_messaging', 'reply' ) && check_user_perm( 'options', 'edit' ) ) { // Check if current user can edit the messaging settings $settings_url = $admin_url.'?ctrl=msgsettings&tab=renderers'; } break; case 'email_apply_rendering': - if( $current_User->check_perm( 'perm_messaging', 'reply' ) && $current_User->check_perm( 'options', 'edit' ) ) + if( check_user_perm( 'perm_messaging', 'reply' ) && check_user_perm( 'options', 'edit' ) ) { // Check if current user can edit the email settings $settings_url = $admin_url.'?ctrl=email&tab=settings&tab3=renderers'; } break; case 'shared_apply_rendering': - if( $current_User->check_perm( 'options', 'edit' ) ) + if( check_user_perm( 'options', 'edit' ) ) { // Check if current user can edit the plugin settings for shared container: $settings_url = $admin_url.'?ctrl=plugins&tab=shared'; } @@ -2421,7 +2428,7 @@ function get_renderer_checkboxes( $current_renderers = NULL, $params ) case 'coll_apply_comment_rendering': case 'coll_apply_rendering': default: - if( ! empty( $setting_Blog ) && $current_User->check_perm( 'blog_properties', 'edit', false, $setting_Blog->ID ) ) + if( ! empty( $setting_Blog ) && check_user_perm( 'blog_properties', 'edit', false, $setting_Blog->ID ) ) { // Check if current user can edit the blog plugin settings $settings_url = $admin_url.'?ctrl=coll_settings&tab=plugins&blog='.$setting_Blog->ID; } diff --git a/inc/plugins/model/_pluginsettings.class.php b/inc/plugins/model/_pluginsettings.class.php index aff9006e88d..fc6c66f6358 100644 --- a/inc/plugins/model/_pluginsettings.class.php +++ b/inc/plugins/model/_pluginsettings.class.php @@ -96,6 +96,24 @@ function delete( $setting ) return parent::delete( $this->plugin_ID, $setting ); } + + /** + * Commit changed plugin settings to DB. + * + * @return boolean true, if settings have been updated; false otherwise + */ + function dbupdate() + { + $result = parent::dbupdate(); + + if( $result ) + { // BLOCK CACHE INVALIDATION: + BlockCache::invalidate_key( 'plugin_ID', $this->plugin_ID ); // Plugin has changed + } + + return $result; + } + } ?> \ No newline at end of file diff --git a/inc/plugins/plugins.ctrl.php b/inc/plugins/plugins.ctrl.php index 0c2ee2c1caf..b3df4f2cc97 100644 --- a/inc/plugins/plugins.ctrl.php +++ b/inc/plugins/plugins.ctrl.php @@ -18,8 +18,8 @@ // Check permission to display: -$current_User->check_perm( 'admin', 'normal', true ); -$current_User->check_perm( 'options', 'view', true ); +check_user_perm( 'admin', 'normal', true ); +check_user_perm( 'options', 'view', true ); load_funcs( 'plugins/_plugin.funcs.php' ); @@ -104,7 +104,7 @@ // Check that this action request is not a CSRF hacked request: $Session->assert_received_crumb( 'plugin' ); - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); param( 'plugin_ID', 'integer', true ); @@ -155,7 +155,7 @@ // Check that this action request is not a CSRF hacked request: $Session->assert_received_crumb( 'plugin' ); - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); param( 'plugin_ID', 'integer', true ); @@ -242,7 +242,7 @@ $Session->assert_received_crumb( 'plugin' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); if( $admin_Plugins->reload_plugins() ) { // Plugins have been changed @@ -268,7 +268,7 @@ $Session->assert_received_crumb( 'plugin' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); param( 'plugin', 'string', true ); @@ -288,7 +288,7 @@ $Session->assert_received_crumb( 'plugin' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); param( 'plugin_ID', 'integer', 0 ); @@ -363,7 +363,7 @@ $Session->assert_received_crumb( 'plugin' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); param( 'plugin_ID', 'integer', true ); param( 'uninstall_confirmed_drop', 'integer', 0 ); @@ -453,7 +453,7 @@ $Session->assert_received_crumb( 'plugin' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); param( 'plugin_ID', 'integer', true ); @@ -628,7 +628,7 @@ case 'edit_settings': // Check permission: - $current_User->check_perm( 'options', 'view', true ); + check_user_perm( 'options', 'view', true ); // Edit plugin settings: param( 'plugin_ID', 'integer', true ); @@ -672,7 +672,7 @@ $Session->assert_received_crumb( 'plugin' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); param( 'plugin_ID', 'integer', true ); @@ -816,7 +816,7 @@ case 'disp_help_plain': // just the help, without any payload // Check permission: (with plugins... you never know...) - $current_User->check_perm( 'options', 'view', true ); + check_user_perm( 'options', 'view', true ); param( 'plugin_class', 'string', true ); @@ -1044,7 +1044,7 @@ // Display plugin info: $Form = new Form( $pagenow ); - if( $edit_Plugin->ID > 0 && $current_User->check_perm( 'options', 'edit', false ) ) + if( $edit_Plugin->ID > 0 && check_user_perm( 'options', 'edit', false ) ) { // Edit settings button (if installed): $Form->global_icon( TB_('Edit plugin settings!'), 'edit', $admin_url.'?ctrl=plugins&action=edit_settings&plugin_ID='.$edit_Plugin->ID ); } diff --git a/inc/plugins/views/_plugin_list.view.php b/inc/plugins/views/_plugin_list.view.php index d4b07681b6d..715a6265356 100644 --- a/inc/plugins/views/_plugin_list.view.php +++ b/inc/plugins/views/_plugin_list.view.php @@ -19,10 +19,6 @@ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); -/** - * @var User - */ -global $current_User; /** * @var Plugins */ @@ -79,9 +75,9 @@ */ function plugin_results_td_status( $plug_status, $plug_ID ) { - global $admin_Plugins, $current_User, $admin_url; + global $admin_Plugins, $admin_url; - $perm_edit = $current_User->check_perm( 'options', 'edit', false ); + $perm_edit = check_user_perm( 'options', 'edit', false ); if( $plug_status == 'enabled' ) { // Enabled @@ -141,10 +137,9 @@ function plugin_results_td_status( $plug_status, $plug_ID ) */ function plugin_results_td_name( $Plugin ) { - global $current_User; $r = ''.$Plugin->name.''; - if( $current_User->check_perm( 'options', 'edit', false ) ) + if( check_user_perm( 'options', 'edit', false ) ) { // Wrap in "edit settings" link: $r = ''.$r.''; @@ -247,7 +242,7 @@ function plugin_results_td_actions( $Plugin ) $r .= action_icon( T_('Un-install this plugin!'), 'delete', $admin_url.'?ctrl=plugins&action=uninstall&plugin_ID='.$Plugin->ID.'&'.url_crumb( 'plugin' ) ); return $r; } -if( $current_User->check_perm( 'options', 'edit', false ) ) +if( check_user_perm( 'options', 'edit', false ) ) { $Results->cols[] = array( 'th' => T_('Actions'), @@ -258,7 +253,7 @@ function plugin_results_td_actions( $Plugin ) // Action icons: -if( $current_User->check_perm( 'options', 'edit' ) ) +if( check_user_perm( 'options', 'edit' ) ) { // Display action link to reload plugins: $Results->global_icon( T_('Reload events and codes for installed plugins.'), 'reload', regenerate_url( 'action', 'action=reload_plugins' ).'&'.url_crumb('plugin'), T_('Reload plugins'), 3, 4 ); } diff --git a/inc/plugins/views/_plugin_list_available.view.php b/inc/plugins/views/_plugin_list_available.view.php index be10e2c8883..216127e0f2d 100644 --- a/inc/plugins/views/_plugin_list_available.view.php +++ b/inc/plugins/views/_plugin_list_available.view.php @@ -16,10 +16,6 @@ load_class( '_core/ui/_table.class.php', 'Table' ); -/** - * @var User - */ -global $current_User; /** * @var Plugins */ @@ -148,7 +144,7 @@ $Table->display_col_start(); $registrations = $admin_Plugins->count_regs($loop_Plugin->classname); - if( $current_User->check_perm( 'options', 'edit', false ) + if( check_user_perm( 'options', 'edit', false ) && ( ! isset( $loop_Plugin->number_of_installs ) || $registrations < $loop_Plugin->number_of_installs ) ) { // number of installations are not limited or not reached yet and user has "edit options" perms diff --git a/inc/plugins/views/_plugin_settings.form.php b/inc/plugins/views/_plugin_settings.form.php index aa6b8254d0f..a8cf29821c0 100644 --- a/inc/plugins/views/_plugin_settings.form.php +++ b/inc/plugins/views/_plugin_settings.form.php @@ -133,7 +133,7 @@ $Form->end_fieldset(); -if( $current_User->check_perm( 'options', 'edit', false ) ) +if( check_user_perm( 'options', 'edit', false ) ) { $Form->buttons_input( array( array( 'type' => 'submit', 'name' => 'actionArray[update_settings]', 'value' => TB_('Save Changes!'), 'class' => 'SaveButton', 'data-shortcut' => 'ctrl+enter,command+enter' ), diff --git a/inc/polls/_polls.init.php b/inc/polls/_polls.init.php index 76bf59cc5d1..86aa6b5fc9e 100644 --- a/inc/polls/_polls.init.php +++ b/inc/polls/_polls.init.php @@ -378,14 +378,14 @@ function handle_htsrv_action() */ function build_menu_2() { - global $admin_url, $current_User, $AdminUI; + global $admin_url, $AdminUI; - if( ! $current_User->check_perm( 'admin', 'restricted' ) ) + if( ! check_user_perm( 'admin', 'restricted' ) ) { // User must has an access to back-office: return; } - if( $current_User->check_perm( 'polls', 'create' ) ) + if( check_user_perm( 'polls', 'create' ) ) { // User has an access at least to view and edit own polls: $AdminUI->add_menu_entries( array( 'site' ), array( 'polls' => array( diff --git a/inc/polls/model/_poll.class.php b/inc/polls/model/_poll.class.php index 6b370011d8d..84100453226 100644 --- a/inc/polls/model/_poll.class.php +++ b/inc/polls/model/_poll.class.php @@ -94,7 +94,7 @@ function load_from_Request() global $current_User; // Owner: - if( $current_User->check_perm( 'polls', 'edit' ) ) + if( check_user_perm( 'polls', 'edit' ) ) { // Update the owner if current user has a permission to edit all polls: $pqst_owner_login = param( 'pqst_owner_login', 'string', NULL ); param_check_not_empty( 'pqst_owner_login', T_('Please enter the owner\'s login.') ); diff --git a/inc/polls/model/_poll.funcs.php b/inc/polls/model/_poll.funcs.php index 94c84219e3f..2534250934b 100644 --- a/inc/polls/model/_poll.funcs.php +++ b/inc/polls/model/_poll.funcs.php @@ -23,11 +23,11 @@ */ function poll_td_question( $Poll ) { - global $current_User, $admin_url; + global $admin_url; $r = $Poll->get_name(); - if( $current_User->check_perm( 'polls', 'view', false, $Poll ) ) + if( check_user_perm( 'polls', 'view', false, $Poll ) ) { // Display the question text as link to view the details: $r = ''.$r.''; } @@ -56,16 +56,16 @@ function poll_td_answers( $Poll ) */ function poll_td_actions( $Poll ) { - global $current_User, $admin_url; + global $admin_url; $r = ''; - if( $current_User->check_perm( 'polls', 'edit', false, $Poll ) ) + if( check_user_perm( 'polls', 'edit', false, $Poll ) ) { // Display the action icons to edit and delete the poll: $r .= action_icon( T_('Edit this poll'), 'edit', $admin_url.'?ctrl=polls&pqst_ID='.$Poll->ID.'&action=edit' ); $r .= action_icon( T_('Delete this poll!'), 'delete', $admin_url.'?ctrl=polls&action=delete&pqst_ID='.$Poll->ID.'&'.url_crumb( 'poll' ) ); } - elseif( $current_User->check_perm( 'polls', 'view', false, $Poll ) ) + elseif( check_user_perm( 'polls', 'view', false, $Poll ) ) { // Display the action icons to view the poll: $r .= action_icon( T_('View this poll'), 'magnifier', $admin_url.'?ctrl=polls&pqst_ID='.$Poll->ID.'&action=edit' ); } @@ -103,7 +103,7 @@ function poll_filters_callback( & $Form ) */ function polls_results_block( $params = array() ) { - global $current_User, $admin_url, $DB; + global $admin_url, $DB; $params = array_merge( array( 'edited_User' => NULL, @@ -116,18 +116,13 @@ function polls_results_block( $params = array() ) 'display_btn_user_del' => false, ), $params ); - if( !is_logged_in() ) - { // Only logged in users can access to this function: - return; - } - - if( ! $current_User->check_perm( 'polls', 'create' ) ) + if( ! check_user_perm( 'polls', 'create' ) ) { // Check minimum permission: return; } // Get permission of current user if all polls are available to view: - $perm_poll_view = $current_User->check_perm( 'polls', 'view' ); + $perm_poll_view = check_user_perm( 'polls', 'view' ); if( ! empty( $params['edited_User'] ) ) { // Use a filter user ID from params: diff --git a/inc/polls/polls.ctrl.php b/inc/polls/polls.ctrl.php index d831b08e9ac..03687fe7e92 100644 --- a/inc/polls/polls.ctrl.php +++ b/inc/polls/polls.ctrl.php @@ -19,7 +19,7 @@ // Check minimum permission: -$current_User->check_perm( 'polls', 'create', true ); +check_user_perm( 'polls', 'create', true ); $AdminUI->set_path( 'site', 'polls' ); @@ -53,14 +53,14 @@ { case 'new': // Check permission: - $current_User->check_perm( 'polls', 'create', true ); + check_user_perm( 'polls', 'create', true ); $edited_Poll = new Poll(); break; case 'edit': // Check permission: - $current_User->check_perm( 'polls', 'view', true, $edited_Poll ); + check_user_perm( 'polls', 'view', true, $edited_Poll ); break; case 'create': @@ -71,7 +71,7 @@ $Session->assert_received_crumb( 'poll' ); // Check that current user has permission to create polls: - $current_User->check_perm( 'polls', 'create', true ); + check_user_perm( 'polls', 'create', true ); // load data from request if( $edited_Poll->load_from_Request() ) @@ -94,7 +94,7 @@ $Session->assert_received_crumb( 'poll' ); // Check that current user has permission to edit the poll: - $current_User->check_perm( 'polls', 'edit', true ); + check_user_perm( 'polls', 'edit', true ); // Make sure we got an pqst_ID: param( 'pqst_ID', 'integer', true ); @@ -120,7 +120,7 @@ $Session->assert_received_crumb( 'poll' ); // Check that current user has permission to edit polls: - $current_User->check_perm( 'polls', 'edit', true, $edited_Poll ); + check_user_perm( 'polls', 'edit', true, $edited_Poll ); // Make sure we got an pqst_ID: param( 'pqst_ID', 'integer', true ); @@ -142,14 +142,14 @@ case 'new_option': // Check permission: - $current_User->check_perm( 'polls', 'edit', true, $edited_Poll ); + check_user_perm( 'polls', 'edit', true, $edited_Poll ); $edited_PollOption = new PollOption(); break; case 'edit_option': // Check permission: - $current_User->check_perm( 'polls', 'edit', true, $edited_Poll ); + check_user_perm( 'polls', 'edit', true, $edited_Poll ); break; case 'create_option': @@ -160,7 +160,7 @@ $Session->assert_received_crumb( 'poll' ); // Check that current user has permission to create polls: - $current_User->check_perm( 'polls', 'edit', true, $edited_Poll ); + check_user_perm( 'polls', 'edit', true, $edited_Poll ); // load data from request if( $edited_PollOption->load_from_Request( $edited_Poll->ID ) ) @@ -183,7 +183,7 @@ $Session->assert_received_crumb( 'poll' ); // Check that current user has permission to edit the poll: - $current_User->check_perm( 'polls', 'edit', true, $edited_Poll ); + check_user_perm( 'polls', 'edit', true, $edited_Poll ); // Make sure we got an pqst_ID: param( 'popt_ID', 'integer', true ); @@ -209,7 +209,7 @@ $Session->assert_received_crumb( 'poll' ); // Check that current user has permission to edit polls: - $current_User->check_perm( 'polls', 'edit', true, $edited_Poll ); + check_user_perm( 'polls', 'edit', true, $edited_Poll ); // Make sure we got an pqst_ID: param( 'popt_ID', 'integer', true ); diff --git a/inc/polls/views/_poll.form.php b/inc/polls/views/_poll.form.php index c0ada7187c4..e9605b2b5e3 100644 --- a/inc/polls/views/_poll.form.php +++ b/inc/polls/views/_poll.form.php @@ -18,7 +18,7 @@ global $edited_Poll, $action, $admin_url; // Get permission of current user if he can edit the edited Poll: -$perm_poll_edit = $current_User->check_perm( 'polls', 'edit', false, $edited_Poll ); +$perm_poll_edit = check_user_perm( 'polls', 'edit', false, $edited_Poll ); // Determine if we are creating or updating: $creating = is_create_action( $action ); @@ -33,7 +33,7 @@ $Form->hidden( 'action', $creating ? 'create' : 'update' ); $Form->hiddens_by_key( get_memorized( 'action'.( $creating ? ',pqst_ID' : '' ) ) ); - if( $current_User->check_perm( 'polls', 'edit' ) ) + if( check_user_perm( 'polls', 'edit' ) ) { // Allow to change an owner if current user has a permission to edit all polls: $Form->username( 'pqst_owner_login', $edited_Poll->get_owner_User(), TB_('Owner'), '', '', array( 'required' => true ) ); } @@ -118,11 +118,11 @@ */ function poll_option_td_option( $PollOption ) { - global $edited_Poll, $current_User, $admin_url; + global $edited_Poll, $admin_url; $r = $PollOption->get_name(); - if( $current_User->check_perm( 'polls', 'edit', false, $edited_Poll ) ) + if( check_user_perm( 'polls', 'edit', false, $edited_Poll ) ) { // Display the option text as link to edit the option details: $r = ''.$r.''; } diff --git a/inc/regional/cities.ctrl.php b/inc/regional/cities.ctrl.php index ec017710e2e..4590b1f38d2 100644 --- a/inc/regional/cities.ctrl.php +++ b/inc/regional/cities.ctrl.php @@ -16,14 +16,9 @@ load_class( 'regional/model/_city.class.php', 'City' ); load_funcs( 'regional/model/_regional.funcs.php' ); -/** - * @var User - */ -global $current_User; - // Check minimum permission: -$current_User->check_perm( 'admin', 'normal', true ); -$current_User->check_perm( 'options', 'view', true ); +check_user_perm( 'admin', 'normal', true ); +check_user_perm( 'options', 'view', true ); // Memorize this as the last "tab" used in the Global Settings: $UserSettings->set( 'pref_glob_settings_tab', $ctrl ); @@ -55,7 +50,7 @@ $Session->assert_received_crumb( 'city' ); // Disable a city only if it is enabled, and user has edit access. - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure the city information was loaded. If not, just exit with error. if( empty($edited_City) ) @@ -93,7 +88,7 @@ $Session->assert_received_crumb( 'city' ); // Disable a city only if it is enabled, and user has edit access. - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure the city information was loaded. If not, just exit with error. if( empty($edited_City) ) @@ -126,7 +121,7 @@ case 'new': // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); if( ! isset($edited_City) ) { // We don't have a model to use, start with blank object: @@ -141,12 +136,12 @@ case 'csv': // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); break; case 'edit': // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure we got an city_ID: param( 'city_ID', 'integer', true ); @@ -162,7 +157,7 @@ $Session->assert_received_crumb( 'city' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Load data from request if( $edited_City->load_from_Request() ) @@ -206,7 +201,7 @@ $Session->assert_received_crumb( 'city' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure we got an city_ID: param( 'city_ID', 'integer', true ); @@ -236,7 +231,7 @@ $Session->assert_received_crumb( 'city' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure we got an city_ID: param( 'city_ID', 'integer', true ); @@ -266,7 +261,7 @@ $Session->assert_received_crumb( 'city' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); set_max_execution_time( 0 ); diff --git a/inc/regional/countries.ctrl.php b/inc/regional/countries.ctrl.php index 04984732e6f..57673a47c9f 100644 --- a/inc/regional/countries.ctrl.php +++ b/inc/regional/countries.ctrl.php @@ -15,14 +15,9 @@ // Load Country class (PHP4): load_class( 'regional/model/_country.class.php', 'Country' ); -/** - * @var User - */ -global $current_User; - // Check minimum permission: -$current_User->check_perm( 'admin', 'normal', true ); -$current_User->check_perm( 'options', 'view', true ); +check_user_perm( 'admin', 'normal', true ); +check_user_perm( 'options', 'view', true ); // Memorize this as the last "tab" used in the Global Settings: $UserSettings->set( 'pref_glob_settings_tab', $ctrl ); @@ -71,7 +66,7 @@ $Session->assert_received_crumb( 'country' ); // Disable a country only if it is enabled, and user has edit access. - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure the country information was loaded. If not, just exit with error. if( empty($edited_Country) ) @@ -106,7 +101,7 @@ $Session->assert_received_crumb( 'country' ); // Disable a country only if it is enabled, and user has edit access. - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure the country information was loaded. If not, just exit with error. if( empty($edited_Country) ) @@ -136,7 +131,7 @@ case 'new': // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); if( ! isset($edited_Country) ) { // We don't have a model to use, start with blank object: @@ -151,7 +146,7 @@ case 'edit': // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure we got an ctry_ID: param( 'ctry_ID', 'integer', true ); @@ -167,7 +162,7 @@ $Session->assert_received_crumb( 'country' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Load data from request if( $edited_Country->load_from_Request() ) @@ -206,7 +201,7 @@ $Session->assert_received_crumb( 'country' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure we got an ctry_ID: param( 'ctry_ID', 'integer', true ); @@ -232,7 +227,7 @@ $Session->assert_received_crumb( 'country' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure we got an ctry_ID: param( 'ctry_ID', 'integer', true ); @@ -261,7 +256,7 @@ if( empty( $action ) ) { // JS to edit status of countries from list view - require_js( 'jquery/jquery.jeditable.js', 'rsc_url' ); + require_js_defer( 'customized:jquery/jeditable/jquery.jeditable.js', 'rsc_url' ); } $AdminUI->breadcrumbpath_init( false ); diff --git a/inc/regional/currencies.ctrl.php b/inc/regional/currencies.ctrl.php index 63b4125012f..aaf5c5bb661 100644 --- a/inc/regional/currencies.ctrl.php +++ b/inc/regional/currencies.ctrl.php @@ -15,14 +15,9 @@ // Load Currency class (PHP4): load_class( 'regional/model/_currency.class.php', 'Currency' ); -/** - * @var User - */ -global $current_User; - // Check minimum permission: -$current_User->check_perm( 'admin', 'normal', true ); -$current_User->check_perm( 'options', 'view', true ); +check_user_perm( 'admin', 'normal', true ); +check_user_perm( 'options', 'view', true ); // Memorize this as the last "tab" used in the Global Settings: $UserSettings->set( 'pref_glob_settings_tab', $ctrl ); @@ -54,7 +49,7 @@ $Session->assert_received_crumb( 'currency' ); // Disable a currency only if it is enabled, and user has edit access. - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure the currency information was loaded. If not, just exit with error. if( empty($edited_Currency) ) @@ -87,7 +82,7 @@ case 'new': // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); if( ! isset($edited_Currency) ) { // We don't have a model to use, start with blank object: @@ -102,7 +97,7 @@ case 'edit': // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure we got an curr_ID: param( 'curr_ID', 'integer', true ); @@ -118,7 +113,7 @@ $Session->assert_received_crumb( 'currency' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Load data from request if( $edited_Currency->load_from_Request() ) @@ -157,7 +152,7 @@ $Session->assert_received_crumb( 'currency' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure we got an curr_ID: param( 'curr_ID', 'integer', true ); @@ -183,7 +178,7 @@ $Session->assert_received_crumb( 'currency' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure we got an curr_ID: param( 'curr_ID', 'integer', true ); diff --git a/inc/regional/model/_regional.funcs.php b/inc/regional/model/_regional.funcs.php index d40612c0eb2..3faa74367d6 100644 --- a/inc/regional/model/_regional.funcs.php +++ b/inc/regional/model/_regional.funcs.php @@ -635,135 +635,12 @@ function echo_regional_js( $prefix, $region_visible ) { // If region is NOT visible we don't need in these ajax functions return; } -?> - - \ No newline at end of file +?> diff --git a/inc/regional/regions.ctrl.php b/inc/regional/regions.ctrl.php index 2ff7f6410c0..3afff37fb85 100644 --- a/inc/regional/regions.ctrl.php +++ b/inc/regional/regions.ctrl.php @@ -16,14 +16,9 @@ load_class( 'regional/model/_region.class.php', 'Region' ); load_funcs( 'regional/model/_regional.funcs.php' ); -/** - * @var User - */ -global $current_User; - // Check minimum permission: -$current_User->check_perm( 'admin', 'normal', true ); -$current_User->check_perm( 'options', 'view', true ); +check_user_perm( 'admin', 'normal', true ); +check_user_perm( 'options', 'view', true ); // Memorize this as the last "tab" used in the Global Settings: $UserSettings->set( 'pref_glob_settings_tab', $ctrl ); @@ -55,7 +50,7 @@ $Session->assert_received_crumb( 'region' ); // Disable a region only if it is enabled, and user has edit access. - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure the region information was loaded. If not, just exit with error. if( empty($edited_Region) ) @@ -93,7 +88,7 @@ $Session->assert_received_crumb( 'region' ); // Disable a region only if it is enabled, and user has edit access. - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure the region information was loaded. If not, just exit with error. if( empty($edited_Region) ) @@ -126,7 +121,7 @@ case 'new': // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); if( ! isset($edited_Region) ) { // We don't have a model to use, start with blank object: @@ -141,12 +136,12 @@ case 'csv': // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); break; case 'edit': // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure we got an rgn_ID: param( 'rgn_ID', 'integer', true ); @@ -162,7 +157,7 @@ $Session->assert_received_crumb( 'region' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Load data from request if( $edited_Region->load_from_Request() ) @@ -201,7 +196,7 @@ $Session->assert_received_crumb( 'region' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure we got an rgn_ID: param( 'rgn_ID', 'integer', true ); @@ -227,7 +222,7 @@ $Session->assert_received_crumb( 'region' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure we got an rgn_ID: param( 'rgn_ID', 'integer', true ); @@ -259,7 +254,7 @@ $Session->assert_received_crumb( 'region' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); set_max_execution_time( 0 ); diff --git a/inc/regional/subregions.ctrl.php b/inc/regional/subregions.ctrl.php index 0ade6746ff9..016c1398a5b 100644 --- a/inc/regional/subregions.ctrl.php +++ b/inc/regional/subregions.ctrl.php @@ -16,14 +16,9 @@ load_class( 'regional/model/_subregion.class.php', 'Subregion' ); load_funcs( 'regional/model/_regional.funcs.php' ); -/** - * @var User - */ -global $current_User; - // Check minimum permission: -$current_User->check_perm( 'admin', 'normal', true ); -$current_User->check_perm( 'options', 'view', true ); +check_user_perm( 'admin', 'normal', true ); +check_user_perm( 'options', 'view', true ); // Memorize this as the last "tab" used in the Global Settings: $UserSettings->set( 'pref_glob_settings_tab', $ctrl ); @@ -55,7 +50,7 @@ $Session->assert_received_crumb( 'subregion' ); // Disable a subregion only if it is enabled, and user has edit access. - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure the subregion information was loaded. If not, just exit with error. if( empty($edited_Subregion) ) @@ -93,7 +88,7 @@ $Session->assert_received_crumb( 'subregion' ); // Disable a subregion only if it is enabled, and user has edit access. - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure the subregion information was loaded. If not, just exit with error. if( empty($edited_Subregion) ) @@ -126,7 +121,7 @@ case 'new': // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); if( ! isset($edited_Subregion) ) { // We don't have a model to use, start with blank object: @@ -141,12 +136,12 @@ case 'csv': // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); break; case 'edit': // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure we got an subrg_ID: param( 'subrg_ID', 'integer', true ); @@ -162,7 +157,7 @@ $Session->assert_received_crumb( 'subregion' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Load data from request if( $edited_Subregion->load_from_Request() ) @@ -202,7 +197,7 @@ $Session->assert_received_crumb( 'subregion' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure we got an subrg_ID: param( 'subrg_ID', 'integer', true ); @@ -229,7 +224,7 @@ $Session->assert_received_crumb( 'subregion' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure we got an subrg_ID: param( 'subrg_ID', 'integer', true ); @@ -261,7 +256,7 @@ $Session->assert_received_crumb( 'subregion' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); set_max_execution_time( 0 ); diff --git a/inc/regional/time.ctrl.php b/inc/regional/time.ctrl.php index 70c6b94a5eb..18b83e69595 100644 --- a/inc/regional/time.ctrl.php +++ b/inc/regional/time.ctrl.php @@ -15,8 +15,8 @@ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); // Check minimum permission: -$current_User->check_perm( 'admin', 'normal', true ); -$current_User->check_perm( 'options', 'view', true ); +check_user_perm( 'admin', 'normal', true ); +check_user_perm( 'options', 'view', true ); // Memorize this as the last "tab" used in the Global Settings: $UserSettings->set( 'pref_glob_settings_tab', $ctrl ); @@ -41,7 +41,7 @@ $Session->assert_received_crumb( 'time' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); param( 'newtime_difference', 'string', '' ); $newtime_difference = trim($newtime_difference); diff --git a/inc/regional/views/_city_list.view.php b/inc/regional/views/_city_list.view.php index f1e990d924e..9263e03c9b5 100644 --- a/inc/regional/views/_city_list.view.php +++ b/inc/regional/views/_city_list.view.php @@ -145,7 +145,7 @@ function filter_cities( & $Form ) $Results->register_filter_preset( 'all', T_('All'), '?ctrl=cities' ); -if( $current_User->check_perm( 'options', 'edit', false ) ) +if( check_user_perm( 'options', 'edit', false ) ) { // We have permission to modify: $Results->cols[] = array( 'th' => T_('Country'), @@ -193,7 +193,7 @@ function filter_cities( & $Form ) ); -if( $current_User->check_perm( 'options', 'edit', false ) ) +if( check_user_perm( 'options', 'edit', false ) ) { // We have permission to modify: $Results->cols[] = array( 'th' => T_('Name'), @@ -237,7 +237,7 @@ function city_td_actions($city_enabled, $city_ID ) return $r; } -if( $current_User->check_perm( 'options', 'edit', false ) ) +if( check_user_perm( 'options', 'edit', false ) ) { $Results->cols[] = array( 'th' => T_('Actions'), diff --git a/inc/regional/views/_country_list.view.php b/inc/regional/views/_country_list.view.php index 6a98e303dad..dde31ff54d5 100644 --- a/inc/regional/views/_country_list.view.php +++ b/inc/regional/views/_country_list.view.php @@ -123,7 +123,7 @@ function ctry_td_preferred( $ctry_preferred, $ctry_ID ) $Results->cols[] = array( 'th' => T_('Status'), - 'td' => /* Check permission: */$current_User->check_perm( 'options', 'edit' ) ? + 'td' => /* Check permission: */check_user_perm( 'options', 'edit' ) ? /* Current user can edit Country */'%ctry_status_title( #ctry_status# )%' : /* No edit, only view the status */'%ctry_status_title( #ctry_status# )%', 'th_class' => 'shrinkwrap', @@ -177,7 +177,7 @@ function filter_countries( & $Form ) ); -if( $current_User->check_perm( 'options', 'edit', false ) ) +if( check_user_perm( 'options', 'edit', false ) ) { // We have permission to modify: $Results->cols[] = array( 'th' => T_('Name'), @@ -256,7 +256,7 @@ function ctry_td_actions($ctry_enabled, $ctry_ID ) return $r; } -if( $current_User->check_perm( 'options', 'edit', false ) ) +if( check_user_perm( 'options', 'edit', false ) ) { $Results->cols[] = array( 'th' => T_('Actions'), @@ -270,7 +270,7 @@ function ctry_td_actions($ctry_enabled, $ctry_ID ) $Results->display(); -if( $current_User->check_perm( 'options', 'edit' ) ) +if( check_user_perm( 'options', 'edit' ) ) { // Check permission to edit Country: // Print JS to edit a country status echo_editable_column_js( array( diff --git a/inc/regional/views/_currency_list.view.php b/inc/regional/views/_currency_list.view.php index e6eea7e354a..709e04f0865 100644 --- a/inc/regional/views/_currency_list.view.php +++ b/inc/regional/views/_currency_list.view.php @@ -79,7 +79,7 @@ function filter_currencies( & $Form ) ); $Results->register_filter_preset( 'all', T_('All'), '?ctrl=currencies' ); -if( $current_User->check_perm( 'options', 'edit', false ) ) +if( check_user_perm( 'options', 'edit', false ) ) { // We have permission to modify: $Results->cols[] = array( 'th' => T_('Code'), @@ -139,7 +139,7 @@ function curr_td_actions($curr_enabled, $curr_ID ) return $r; } -if( $current_User->check_perm( 'options', 'edit', false ) ) +if( check_user_perm( 'options', 'edit', false ) ) { // We have permission to modify: $Results->cols[] = array( 'th' => T_('Actions'), diff --git a/inc/regional/views/_region_list.view.php b/inc/regional/views/_region_list.view.php index a02805dde45..aa9c067b99d 100644 --- a/inc/regional/views/_region_list.view.php +++ b/inc/regional/views/_region_list.view.php @@ -128,7 +128,7 @@ function filter_regions( & $Form ) $Results->register_filter_preset( 'all', T_('All'), '?ctrl=regions' ); -if( $current_User->check_perm( 'options', 'edit', false ) ) +if( check_user_perm( 'options', 'edit', false ) ) { // We have permission to modify: $Results->cols[] = array( 'th' => T_('Country'), @@ -158,7 +158,7 @@ function filter_regions( & $Form ) ); -if( $current_User->check_perm( 'options', 'edit', false ) ) +if( check_user_perm( 'options', 'edit', false ) ) { // We have permission to modify: $Results->cols[] = array( 'th' => T_('Name'), @@ -203,7 +203,7 @@ function rgn_td_actions($rgn_enabled, $rgn_ID ) return $r; } -if( $current_User->check_perm( 'options', 'edit', false ) ) +if( check_user_perm( 'options', 'edit', false ) ) { $Results->cols[] = array( 'th' => T_('Actions'), diff --git a/inc/regional/views/_subregion_list.view.php b/inc/regional/views/_subregion_list.view.php index 7a265b37e9a..93aba65b948 100644 --- a/inc/regional/views/_subregion_list.view.php +++ b/inc/regional/views/_subregion_list.view.php @@ -136,7 +136,7 @@ function filter_subregions( & $Form ) $Results->register_filter_preset( 'all', T_('All'), '?ctrl=subregions' ); -if( $current_User->check_perm( 'options', 'edit', false ) ) +if( check_user_perm( 'options', 'edit', false ) ) { // We have permission to modify: $Results->cols[] = array( 'th' => T_('Country'), @@ -174,7 +174,7 @@ function filter_subregions( & $Form ) ); -if( $current_User->check_perm( 'options', 'edit', false ) ) +if( check_user_perm( 'options', 'edit', false ) ) { // We have permission to modify: $Results->cols[] = array( 'th' => T_('Name'), @@ -219,7 +219,7 @@ function subrg_td_actions($subrg_enabled, $subrg_ID ) return $r; } -if( $current_User->check_perm( 'options', 'edit', false ) ) +if( check_user_perm( 'options', 'edit', false ) ) { $Results->cols[] = array( 'th' => T_('Actions'), diff --git a/inc/regional/views/_time.form.php b/inc/regional/views/_time.form.php index c7214316329..17ab4f9f0fe 100644 --- a/inc/regional/views/_time.form.php +++ b/inc/regional/views/_time.form.php @@ -15,10 +15,6 @@ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); -/** - * @var User - */ -global $current_User; /** * @var GeneralSettings */ @@ -113,7 +109,7 @@ function calc_TimeDifference(min_dif) { $Form->end_fieldset(); -if( $current_User->check_perm( 'options', 'edit' ) ) +if( check_user_perm( 'options', 'edit' ) ) { $Form->end_form( array( array( 'submit', '', TB_('Save Changes!'), 'SaveButton' ) ) ) ; } diff --git a/inc/rest/_restapi.class.php b/inc/rest/_restapi.class.php index 5ea8f587089..476484bc8f8 100644 --- a/inc/rest/_restapi.class.php +++ b/inc/rest/_restapi.class.php @@ -377,9 +377,7 @@ private function module_collections() } elseif( $allow_access == 'members' ) { // Check if current user is member of the collection: - global $current_User; - - if( ! $current_User->check_perm( 'blog_ismember', 'view', false, $Blog->ID ) ) + if( ! check_user_perm( 'blog_ismember', 'view', false, $Blog->ID ) ) { // Current user cannot access to the collection: $this->halt( T_('You are not a member of this section, therefore you are not allowed to access it.'), 'access_denied', 403 ); // Exit here. @@ -473,8 +471,8 @@ private function controller_coll_() if( $api_restrict_to_available_fileroots && ( ! is_logged_in() || - ! $current_User->check_perm( 'admin', 'restricted' ) || - ! $current_User->check_perm( 'files', 'view' ) + ! check_user_perm( 'admin', 'restricted' ) || + ! check_user_perm( 'files', 'view' ) ) ) { // Anonymous user has no access to file roots AND also if current use has no access to back-office or to file manager: $result_count = 0; @@ -484,7 +482,7 @@ private function controller_coll_() if( $api_restrict_to_available_fileroots ) { // Restrict collections by available file roots for current user: - // SQL analog for $current_User->check_perm( 'blogs', 'view' ) || $current_User->check_perm( 'files', 'edit' ): + // SQL analog for check_user_perm( 'blogs', 'view' ) || check_user_perm( 'files', 'edit' ): $current_User->get_Group(); $check_perm_blogs_view_files_edit_SQL = new SQL(); $check_perm_blogs_view_files_edit_SQL->SELECT( 'grp_ID' ); @@ -494,7 +492,7 @@ private function controller_coll_() $check_perm_blogs_view_files_edit_SQL->WHERE_and( 'grp_perm_blogs IN ( "viewall", "editall" ) OR gset_value IS NULL OR gset_value IN ( "all", "edit" )' ); $restrict_available_fileroots_sql = '( '.$check_perm_blogs_view_files_edit_SQL->get().' )'; - // SQL analog for $current_User->check_perm( 'blog_media_browse', 'view', false, $Blog ): + // SQL analog for check_user_perm( 'blog_media_browse', 'view', false, $Blog ): $check_perm_blog_media_browse_user_SQL = new SQL(); $check_perm_blog_media_browse_user_SQL->SELECT( 'bloguser_blog_ID' ); $check_perm_blog_media_browse_user_SQL->FROM( 'T_coll_user_perms' ); @@ -611,8 +609,6 @@ private function controller_coll_linked() */ private function controller_coll_view() { - global $current_User; - $coll_urlname = empty( $this->args[1] ) ? 0 : $this->args[1]; $BlogCache = & get_BlogCache(); @@ -1115,9 +1111,9 @@ private function controller_coll_search() */ private function controller_coll_assignees() { - global $current_User, $Collection, $Blog, $DB; + global $Collection, $Blog, $DB; - if( ! is_logged_in() || ! $current_User->check_perm( 'blog_can_be_assignee', 'edit', false, $Blog->ID ) ) + if( ! check_user_perm( 'blog_can_be_assignee', 'edit', false, $Blog->ID ) ) { // Check permission: Current user must has a permission to be assignee of the collection: $this->halt( 'You are not allowed to view assigness of the collection "'.$Blog->get( 'name' ).'".', 'no_access', 403 ); // Exit here. @@ -1392,7 +1388,7 @@ private function controller_user_() global $current_User; if( is_logged_in() ) { // Check perms for logged in user: - if( ! ( $current_User->check_perm( 'users', 'moderate' ) && $current_User->check_perm( 'files', 'all' ) ) ) + if( ! ( check_user_perm( 'users', 'moderate' ) && check_user_perm( 'files', 'all' ) ) ) { // Current user has an access only to file root of own account: $user_filters = array( 'userids' => array( $current_User->ID ) ); } @@ -1492,8 +1488,6 @@ private function controller_user_() */ private function controller_user_view() { - global $current_User; - // Get an user ID for request "GET /api/v1/users/": $user_ID = intval( empty( $this->args[1] ) ? 0 : $this->args[1] ); @@ -1522,7 +1516,7 @@ private function controller_user_view() $user_data['picture'] = $user_picture; // Other pictures: $user_data['pictures'] = array(); - if( is_logged_in() && $current_User->check_status( 'can_view_user', $user_ID ) ) + if( check_user_status( 'can_view_user', $user_ID ) ) { // Display other pictures, but only for logged in and activated users: $user_pic_links = $User->get_avatar_Links(); foreach( $user_pic_links as $user_pic_Link ) @@ -1660,7 +1654,7 @@ private function controller_user_delete() { global $current_User; - if( ! is_logged_in() || ! $current_User->check_perm( 'users', 'edit' ) ) + if( ! check_user_perm( 'users', 'edit' ) ) { // Current user has no permission to delete the requested user: $this->halt( T_('You have no permission to edit other users!'), 'no_access', 403 ); // Exit here. @@ -1720,7 +1714,7 @@ private function controller_user_recipients() { global $current_User, $DB; - if( ! is_logged_in() || ! $current_User->check_perm( 'perm_messaging', 'reply' ) ) + if( ! check_user_perm( 'perm_messaging', 'reply' ) ) { // Check permission: User is not allowed to view threads $this->halt( 'You are not allowed to view recipients.', 'no_access', 403 ); // Exit here. @@ -1857,8 +1851,6 @@ private function controller_user_autocomplete() */ private function controller_user_logins() { - global $current_User; - $api_q = trim( urldecode( param( 'q', 'string', '' ) ) ); $api_status = param( 'status', 'string', '' ); @@ -1899,7 +1891,7 @@ private function controller_user_logins() $users = $this->func_user_search( $api_q, $func_user_search_params ); // Check if current user can see other users with ALL statuses: - $can_view_all_users = ( is_logged_in() && $current_User->check_perm( 'users', 'view' ) ); + $can_view_all_users = check_user_perm( 'users', 'view' ); $user_logins = array(); foreach( $users as $User ) @@ -2129,7 +2121,7 @@ private function module_polls() { $polls = array(); - $perm_poll_view = $current_User->check_perm( 'polls', 'view' ); + $perm_poll_view = check_user_perm( 'polls', 'view' ); $polls_SQL = new SQL(); $polls_SQL->SELECT( 'pqst_ID, pqst_owner_user_ID, pqst_question_text' ); @@ -2349,7 +2341,8 @@ private function controller_link_change_position() // Update last touched date of Owners $LinkOwner->update_last_touched_date(); - if( $link_position == 'cover' && $LinkOwner->type == 'item' ) + if( $LinkOwner->type == 'item' && + ( $link_position == 'cover' || $link_position == 'background' ) ) { // Position "Cover" can be used only by one link // Replace previous position with "Inline" $DB->query( 'UPDATE T_links diff --git a/inc/sessions/_sessions.init.php b/inc/sessions/_sessions.init.php index 8dfbca3cb3d..dc0132f522e 100644 --- a/inc/sessions/_sessions.init.php +++ b/inc/sessions/_sessions.init.php @@ -131,16 +131,15 @@ function build_evobar_menu() * @var Menu */ global $topleft_Menu; - global $current_User; global $admin_url; global $Collection, $Blog, $activate_collection_toolbar; - if( !$current_User->check_perm( 'admin', 'normal' ) ) + if( ! check_user_perm( 'admin', 'normal' ) ) { return; } - if( ( ! is_admin_page() || ! empty( $activate_collection_toolbar ) ) && ! empty( $Blog ) && $current_User->check_perm( 'stats', 'list', false, $Blog->ID ) ) + if( ( ! is_admin_page() || ! empty( $activate_collection_toolbar ) ) && ! empty( $Blog ) && check_user_perm( 'stats', 'list', false, $Blog->ID ) ) { // Permission to view stats for user's blogs: $entries = array( 'stats_separator' => array( 'separator' => true ), @@ -172,7 +171,7 @@ function build_evobar_menu() $topleft_Menu->add_menu_entries( 'blog', $entries ); } - if( $current_User->check_perm( 'stats', 'view' ) ) + if( check_user_perm( 'stats', 'view' ) ) { // We have permission to view all stats $entries = array( 'stats_separator' => array( 'separator' => true ), @@ -238,22 +237,18 @@ function build_evobar_menu() function build_menu_1() { global $blog, $sec_ID, $admin_url; - /** - * @var User - */ - global $current_User; global $Collection, $Blog; /** * @var AdminUI_general */ global $AdminUI; - if( !$current_User->check_perm( 'admin', 'normal' ) ) + if( ! check_user_perm( 'admin', 'normal' ) ) { return; } - if( $current_User->check_perm( 'stats', 'list' ) ) + if( check_user_perm( 'stats', 'list' ) ) { // Permission to view stats for user's blogs: // Initialize params to filter by selected collection and/or group: @@ -301,7 +296,7 @@ function build_menu_1() 'text' => T_('Top IPs'), 'href' => $admin_url.'?ctrl=stats&tab=ips'.$section_params ) ); - if( $current_User->check_perm( 'spamblacklist', 'view' ) ) + if( check_user_perm( 'spamblacklist', 'view' ) ) { // Display IP ranges only if current user has access to view Antispam tools $ips_entries['ranges'] = array( 'text' => T_('IP Ranges'), @@ -354,7 +349,7 @@ function build_menu_1() ) ); - if( $current_User->check_perm( 'stats', 'view' ) || + if( check_user_perm( 'stats', 'view' ) || autoselect_blog( 'stats', 'view' ) ) { // Viewing aggregate + Permission to view stats for ALL blogs: $AdminUI->add_menu_entries( diff --git a/inc/sessions/goals.ctrl.php b/inc/sessions/goals.ctrl.php index 917833f777c..0a179a5c479 100644 --- a/inc/sessions/goals.ctrl.php +++ b/inc/sessions/goals.ctrl.php @@ -17,22 +17,17 @@ load_class( 'sessions/model/_goalcat.class.php', 'GoalCategory' ); load_funcs( 'sessions/model/_hitlog.funcs.php' ); -/** - * @var User - */ -global $current_User; - global $collections_Module; // We should activate toolbar menu items for this controller $activate_collection_toolbar = true; // Do we have permission to view all stats (aggregated stats) ? -$perm_view_all = $current_User->check_perm( 'stats', 'view' ); +$perm_view_all = check_user_perm( 'stats', 'view' ); // Section ID: param( 'sec_ID', 'integer', 0, true ); -if( ! $perm_view_all && ! $current_User->check_perm( 'section', 'view', false, $sec_ID ) ) +if( ! $perm_view_all && ! check_user_perm( 'section', 'view', false, $sec_ID ) ) { forget_param( 'sec_ID' ); unset( $sec_ID ); @@ -75,7 +70,7 @@ } // Check permission to view current blog -$current_User->check_perm( 'stats', 'list', true, $blog ); +check_user_perm( 'stats', 'list', true, $blog ); if( param( 'goal_ID', 'integer', '', true) ) { // Load goal: @@ -107,7 +102,7 @@ case 'new': case 'copy': // Check permission: - $current_User->check_perm( 'stats', 'edit', true ); + check_user_perm( 'stats', 'edit', true ); if( ! isset( $edited_Goal ) ) { // We don't have a model to use, start with blank object: @@ -124,7 +119,7 @@ // Edit goal form...: // Check permission: - $current_User->check_perm( 'stats', 'edit', true ); + check_user_perm( 'stats', 'edit', true ); // Make sure we got an ftyp_ID: param( 'goal_ID', 'integer', true ); @@ -140,7 +135,7 @@ $Session->assert_received_crumb( 'goal' ); // Check permission: - $current_User->check_perm( 'stats', 'edit', true ); + check_user_perm( 'stats', 'edit', true ); // load data from request if( $edited_Goal->load_from_Request() ) @@ -179,7 +174,7 @@ $Session->assert_received_crumb( 'goal' ); // Check permission: - $current_User->check_perm( 'stats', 'edit', true ); + check_user_perm( 'stats', 'edit', true ); // Make sure we got an ftyp_ID: param( 'goal_ID', 'integer', true ); @@ -208,7 +203,7 @@ $Session->assert_received_crumb( 'goal' ); // Check permission: - $current_User->check_perm( 'stats', 'edit', true ); + check_user_perm( 'stats', 'edit', true ); // Make sure we got an ftyp_ID: param( 'goal_ID', 'integer', true ); @@ -239,7 +234,7 @@ // New goal category form...: // Check permission: - $current_User->check_perm( 'stats', 'edit', true ); + check_user_perm( 'stats', 'edit', true ); if( ! isset( $edited_GoalCategory ) ) { // We don't have a model to use, start with blank object: @@ -256,7 +251,7 @@ // Edit goal category form...: // Check permission: - $current_User->check_perm( 'stats', 'edit', true ); + check_user_perm( 'stats', 'edit', true ); // Make sure we got an ftyp_ID: param( 'gcat_ID', 'integer', true ); @@ -272,7 +267,7 @@ $Session->assert_received_crumb( 'goalcat' ); // Check permission: - $current_User->check_perm( 'stats', 'edit', true ); + check_user_perm( 'stats', 'edit', true ); // load data from request if( $edited_GoalCategory->load_from_Request() ) @@ -313,7 +308,7 @@ $Session->assert_received_crumb( 'goalcat' ); // Check permission: - $current_User->check_perm( 'stats', 'edit', true ); + check_user_perm( 'stats', 'edit', true ); // Make sure we got an ftyp_ID: param( 'gcat_ID', 'integer', true ); @@ -343,7 +338,7 @@ $Session->assert_received_crumb( 'goalcat' ); // Check permission: - $current_User->check_perm( 'stats', 'edit', true ); + check_user_perm( 'stats', 'edit', true ); // Make sure we got an ftyp_ID: param( 'gcat_ID', 'integer', true ); @@ -382,7 +377,7 @@ $Session->assert_received_crumb( 'aggregate' ); // Check permission: - $current_User->check_perm( 'stats', 'edit', true ); + check_user_perm( 'stats', 'edit', true ); load_class( 'sessions/model/_hitlist.class.php', 'Hitlist' ); @@ -401,7 +396,7 @@ $Session->assert_received_crumb( 'goals' ); // Check permission: - $current_User->check_perm( 'stats', 'edit', true ); + check_user_perm( 'stats', 'edit', true ); param( 'date', 'integer', true ); // Required! if( $r = Hitlist::prune_goal_hits( $date ) ) diff --git a/inc/sessions/model/_goal.class.php b/inc/sessions/model/_goal.class.php index 09b68732632..d05524749cd 100644 --- a/inc/sessions/model/_goal.class.php +++ b/inc/sessions/model/_goal.class.php @@ -101,12 +101,7 @@ function get_action_title( $action ) */ function check_perm( $action= 'view', $assert = true ) { - /** - * @var User - */ - global $current_User; - - return $current_User->check_perm( 'stats', $action, $assert ); + return check_user_perm( 'stats', $action, $assert ); } diff --git a/inc/sessions/model/_hit.class.php b/inc/sessions/model/_hit.class.php index ff00d8615c9..15dd57517a0 100644 --- a/inc/sessions/model/_hit.class.php +++ b/inc/sessions/model/_hit.class.php @@ -414,7 +414,7 @@ function detect_referer( $referer = NULL ) $pos = strpos( $this->referer, $self_referer ); // If not starting within in the first 12 chars it's probably an url param as in &url=http://this_blog.com if( $pos !== false && $pos <= 12 && - ! ( $debug && strpos( $this->referer, '/search.html' ) ) ) // search simulation + ! ( $debug && strpos( $this->referer, '/search.html' ) ) ) // search simulation { // This type may be superseeded by admin page if( ! $this->detect_admin_page() ) @@ -697,7 +697,7 @@ function detect_useragent() } if( ! $match && ( $browscap = $this->get_browser_caps() ) && - isset( $browscap->crawler ) && $browscap->crawler ) + isset( $browscap->crawler ) && $browscap->crawler ) { $Debuglog->add( 'Hit:detect_useragent(): robot (through browscap)', 'request' ); $this->agent_type = 'robot'; @@ -1306,11 +1306,14 @@ function get_search_engine_names() if( is_null( $this->search_engine_names ) ) { $this->search_engine_names = array(); + + $search_engine_params = get_search_engine_params(); + foreach( $search_engine_params as $url => $info ) { - if( ! isset( $this->search_engine_names[$info[0]] ) ) + if( ! isset( $this->search_engine_names[$info['name']] ) ) { // Do not overwrite existing keys - $this->search_engine_names[$info[0]] = $url; + $this->search_engine_names[$info['name']] = $url; } } } @@ -1450,9 +1453,6 @@ function is_search_referer( $referer, $return_params = false ) { global $search_engine_params; - // Load search engine definitions - require_once dirname(__FILE__).'/_search_engines.php'; - // Parse referer: $pu = @parse_url( $referer ); @@ -1461,6 +1461,10 @@ function is_search_referer( $referer, $return_params = false ) return false; } + // Load search engine definitions + load_funcs( 'sessions/model/_hitlog.funcs.php' ); + $search_engine_params = get_search_engine_params(); + $ref_host = $pu['host']; $ref_query = isset( $pu['query'] ) ? $pu['query'] : ''; $ref_fragment = isset( $pu['fragment'] ) ? $pu['fragment'] : ''; @@ -1541,19 +1545,23 @@ function extract_params_from_referer( $ref ) return false; } - $search_engine_name = $search_engine_params[$ref_host][0]; + // Load search engine definitions + load_funcs( 'sessions/model/_hitlog.funcs.php' ); + $search_engine_params = get_search_engine_params(); + + $search_engine_name = $search_engine_params[$ref_host]['name']; $keyword_param = NULL; - if( ! empty( $search_engine_params[$ref_host][1] ) ) + if( ! empty( $search_engine_params[$ref_host]['params'] ) ) { - $keyword_param = $search_engine_params[$ref_host][1]; + $keyword_param = $search_engine_params[$ref_host]['params']; } if( is_null( $keyword_param ) ) { // Get settings from first item in group $search_engine_names = $this->get_search_engine_names(); $url = $search_engine_names[$search_engine_name]; - $keyword_param = $search_engine_params[$url][1]; + $keyword_param = $search_engine_params[$url]['params']; } if( ! is_array( $keyword_param ) ) { @@ -1568,7 +1576,7 @@ function extract_params_from_referer( $ref ) $query = str_replace( '&', '&', strstr( $query, '?' ) ); } elseif( $search_engine_name == 'Google' && ( strpos( $query, '&as_' ) !== false || strpos( $query, 'as_' ) === 0 ) ) - { // Google with "as_" param + { // Google with "as_" param $keys = array(); if( $key = $this->get_param_from_string( $query, 'as_q' ) ) @@ -1630,10 +1638,42 @@ function extract_params_from_referer( $ref ) } } + // Use 'hiddenkeyword' param from search engine definitions to check + // if the search engine refers from paths that may not contain/provide a keyword: + if( ! $key_param_in_query && ! empty( $search_engine_params[$ref_host]['hiddenkeyword'] ) ) + { + $path_with_query_and_fragment = $ref_path; + if( !empty( $query ) ) + { + $path_with_query_and_fragment .= '?'.$query; + } + if( !empty( $fragment ) ) + { + $path_with_query_and_fragment .= '#'.$fragment; + } + + foreach( $search_engine_params[$ref_host]['hiddenkeyword'] as $path ) + { + if( strlen( $path ) > 1 && substr( $path, 0, 1 ) == '/' && substr( $path, -1,1 ) == '/' ) + { + if( preg_match( $path, $path_with_query_and_fragment ) ) + { + $key_param_in_query = true; + break; + } + } + elseif( $path == $path_with_query_and_fragment ) + { + $key_param_in_query = true; + break; + } + } + } + if( empty( $key ) && ! $key_param_in_query ) - { // Not a search referer + { // Not a search referer if( $this->referer_type == 'search' ) - { // If the referer was detected as 'search' we need to change it to 'special' + { // If the referer was detected as 'search' we need to change it to 'special' // to keep search stats clean. $this->referer_type = 'special'; $Debuglog->add( 'Hit: extract_params_from_referer() overrides referer type set by detect_referer(): "search" -> "special"', 'request' ); @@ -1644,13 +1684,13 @@ function extract_params_from_referer( $ref ) // Convert encoding: - if( ! empty( $search_engine_params[$ref_host][3] ) ) + if( ! empty( $search_engine_params[$ref_host]['charsets'] ) ) { - $ie = $search_engine_params[$ref_host][3]; + $ie = $search_engine_params[$ref_host]['charsets']; } - elseif( isset( $url ) && ! empty( $search_engine_params[$url][3] ) ) + elseif( isset( $url ) && ! empty( $search_engine_params[$url]['charsets'] ) ) { - $ie = $search_engine_params[$url][3]; + $ie = $search_engine_params[$url]['charsets']; } else { // Fallback to default encoding: @@ -1685,6 +1725,10 @@ function extract_params_from_referer( $ref ) // Extract the "serp rank" // Typically http://google.com?s=keyphraz&start=18 returns 18 + + // There is no longer a 'serp rank' param in the latest search engine definitions, + // we will have to resort to the fallback param values: + /* if( ! empty( $search_engine_params[$ref_host][4] ) ) { $serp_param = $search_engine_params[$ref_host][4]; @@ -1697,6 +1741,9 @@ function extract_params_from_referer( $ref ) { // Fallback to default params $serp_param = array( 'offset', 'page', 'start' ); } + */ + // Fallback to default params + $serp_param = array( 'offset', 'page', 'start' ); if( ! is_array( $serp_param ) ) { @@ -1951,4 +1998,4 @@ function get_browser_version() } } -?> \ No newline at end of file +?> diff --git a/inc/sessions/model/_hitlist.class.php b/inc/sessions/model/_hitlist.class.php index d8e7d827185..b13c91f5268 100644 --- a/inc/sessions/model/_hitlist.class.php +++ b/inc/sessions/model/_hitlist.class.php @@ -144,7 +144,7 @@ static function dbprune( $output_message = true, $day_limit = true ) $Messages->add( $error_message, 'error' ); } if( $day_limit ) - { // Limit a pruning by one execution per day: + { // Limit pruning to one execution per day: return array( 'result' => 'error', 'message' => $error_message @@ -188,10 +188,19 @@ static function dbprune( $output_message = true, $day_limit = true ) $return_message .= Hitlist::log_pruning( sprintf( 'Aggregate the rows from %s to %s, Execution time: %s seconds', 'T_track__goalhit', 'T_track__goalhit_aggregate', $hitlist_Timer->get_duration( 'aggregate_goal_hits' ) ), $output_message, true ); // Aggregate the counts of unique sessions: - $hitlist_Timer->start( 'aggregate_sessions' ); - Hitlist::aggregate_sessions(); - $hitlist_Timer->stop( 'aggregate_sessions' ); - $return_message .= Hitlist::log_pruning( sprintf( 'Aggregate the rows from %s to %s, Execution time: %s seconds', 'T_hitlog', 'T_hits__aggregate_sessions', $hitlist_Timer->get_duration( 'aggregate_sessions' ) ), $output_message, true ); + $session_types = array( + 'coll_browser' => 'ONLY collection browser sessions', + 'coll_api' => 'ONLY collection API sessions', + 'all_browser' => 'ALL browser sessions', + 'all_api' => 'ALL API sessions', + ); + foreach( $session_types as $session_type => $session_type_desc ) + { + $hitlist_Timer->start( 'aggregate_sessions_'.$session_type ); + Hitlist::aggregate_sessions( $session_type ); + $hitlist_Timer->stop( 'aggregate_sessions_'.$session_type ); + $return_message .= Hitlist::log_pruning( sprintf( 'Aggregate '.$session_type_desc.' from %s to %s, Execution time: %s seconds', 'T_hitlog', 'T_hits__aggregate_sessions', $hitlist_Timer->get_duration( 'aggregate_sessions_'.$session_type ) ), $output_message, true ); + } // PRUNE: $return_message .= Hitlist::log_pruning( "\n".'PRUNING:', $output_message ); @@ -226,16 +235,39 @@ static function dbprune( $output_message = true, $day_limit = true ) $Plugins->trigger_event( 'BeforeSessionsDelete', $temp_array = array( 'cutoff_timestamp' => $oldest_date ) ); // PRUNE SESSIONS: - $hitlist_Timer->start( 'sessions' ); - $sessions_rows_affected = $DB->query( 'DELETE FROM T_sessions - WHERE - ( sess_user_ID IS NOT NULL AND sess_lastseen_ts < '.$DB->quote( date( 'Y-m-d H:i:s', $oldest_date ) ).' ) - OR - ( sess_user_ID IS NULL AND sess_lastseen_ts < '.$DB->quote( date( 'Y-m-d H:i:s', $time_prune_before ) ).' )', - 'Autoprune sessions' ); - $hitlist_Timer->stop( 'sessions' ); - $Debuglog->add( 'Hitlist::dbprune(): autopruned '.$sessions_rows_affected.' rows from T_sessions.', 'request' ); - $return_message .= Hitlist::log_pruning( sprintf( '%s rows from %s, Execution time: %s seconds', $sessions_rows_affected, 'T_sessions', $hitlist_Timer->get_duration( 'sessions' ) ), $output_message, true ); + $sessions_rows_affected_total = 0; + $sessions_rows_affected_i = 1; + $sessions_i = 0; + $hitlist_Timer->start( 'sessions_total' ); + while( $sessions_rows_affected_i ) + { + $hitlist_Timer->start( 'sessions_i' ); + $sessions_rows_affected_i = $DB->query( 'DELETE FROM T_sessions + WHERE + ( sess_user_ID IS NOT NULL AND sess_lastseen_ts < '.$DB->quote( date( 'Y-m-d H:i:s', $oldest_date ) ).' ) + OR + ( sess_user_ID IS NULL AND sess_lastseen_ts < '.$DB->quote( date( 'Y-m-d H:i:s', $time_prune_before ) ).' ) + LIMIT 1000', + 'Autoprune sessions' ); + $hitlist_Timer->stop( 'sessions_i' ); + if( $sessions_i == 0 || $sessions_rows_affected_i > 0 ) + { + $Debuglog->add( 'Hitlist::dbprune(): autopruned '.$sessions_rows_affected_i.' rows from T_sessions.', 'request' ); + $return_message .= Hitlist::log_pruning( sprintf( '%s rows from %s, Execution time: %s seconds', $sessions_rows_affected_i, 'T_sessions', $hitlist_Timer->get_duration( 'sessions_i' ) ), $output_message, true ); + $sessions_rows_affected_total += $sessions_rows_affected_i; + } + $sessions_i++; + if( $sessions_rows_affected_i < 1000 ) + { // Don't try next query if current already is less 1000 records: + break; + } + } + $hitlist_Timer->stop( 'sessions_total' ); + if( $sessions_i > 1 ) + { // Display total pruned sessions only if it was executed more 1 time per 1000 limited records: + $Debuglog->add( 'Hitlist::dbprune(): Total autopruned '.$sessions_rows_affected_total.' rows from T_sessions.', 'request' ); + $return_message .= Hitlist::log_pruning( sprintf( 'Total %s rows from %s, Execution time: %s seconds', $sessions_rows_affected_total, 'T_sessions', $hitlist_Timer->get_duration( 'sessions_total' ) ), $output_message, true ); + } // PRUNE BASEDOMAINS: @@ -319,50 +351,65 @@ static function aggregate_hits() /** * Aggregate the counts of unique sessions + * + * @param string What to aggregate? + * - all: ALL sessions + * - coll_browser: ONLY collection browser sessions + * - coll_api: ONLY collection API sessions + * - all_browser: ALL browser sessions + * - all_api: ALL API sessions */ - static function aggregate_sessions() + static function aggregate_sessions( $type = 'all' ) { global $DB; // NOTE: Do NOT aggregate current day because it is not ended yet $max_aggregate_date = date( 'Y-m-d H:i:s', mktime( 0, 0, 0 ) ); - // ONLY collection browser sessions: - $DB->query( 'REPLACE INTO T_hits__aggregate_sessions ( hags_date, hags_coll_ID, hags_count_browser ) - SELECT DATE( hit_datetime ) AS hit_date, hit_coll_ID, COUNT( DISTINCT hit_sess_ID ) - FROM T_hitlog - WHERE hit_datetime < '.$DB->quote( $max_aggregate_date ).' - AND hit_agent_type = "browser" - AND hit_coll_ID > 0 - GROUP BY hit_date, hit_coll_ID', - 'Aggregate ONLY collection sessions from hit log (hit_agent_type = "browser")' ); - // ONLY collection API sessions: - $DB->query( 'INSERT INTO T_hits__aggregate_sessions ( hags_date, hags_coll_ID, hags_count_api ) - SELECT DATE( hit_datetime ) AS hit_date, hit_coll_ID, COUNT( DISTINCT hit_sess_ID ) - FROM T_hitlog - WHERE hit_datetime < '.$DB->quote( $max_aggregate_date ).' - AND hit_type = "api" - AND hit_coll_ID > 0 - GROUP BY hit_date, hit_coll_ID - ON DUPLICATE KEY UPDATE hags_count_api = VALUES( hags_count_api )', - 'Aggregate ONLY collection sessions from hit log (hit_type = "api")' ); - // ALL browser sessions: - $DB->query( 'REPLACE INTO T_hits__aggregate_sessions ( hags_date, hags_coll_ID, hags_count_browser ) - SELECT DATE( hit_datetime ) AS hit_date, 0, COUNT( DISTINCT hit_sess_ID ) - FROM T_hitlog - WHERE hit_datetime < '.$DB->quote( $max_aggregate_date ).' - AND hit_agent_type = "browser" - GROUP BY hit_date', - 'Aggregate ALL sessions from hit log (hit_agent_type = "browser")' ); - // ALL API sessions: - $DB->query( 'INSERT INTO T_hits__aggregate_sessions ( hags_date, hags_coll_ID, hags_count_api ) - SELECT DATE( hit_datetime ) AS hit_date, 0, COUNT( DISTINCT hit_sess_ID ) - FROM T_hitlog - WHERE hit_datetime < '.$DB->quote( $max_aggregate_date ).' - AND hit_type = "api" - GROUP BY hit_date - ON DUPLICATE KEY UPDATE hags_count_api = VALUES( hags_count_api )', - 'Aggregate ALL sessions from hit log (hit_type = "api")' ); + if( $type == 'all' || $type == 'coll_browser' ) + { // ONLY collection browser sessions: + $DB->query( 'REPLACE INTO T_hits__aggregate_sessions ( hags_date, hags_coll_ID, hags_count_browser ) + SELECT DATE( hit_datetime ) AS hit_date, hit_coll_ID, COUNT( DISTINCT hit_sess_ID ) + FROM T_hitlog + WHERE hit_datetime < '.$DB->quote( $max_aggregate_date ).' + AND hit_agent_type = "browser" + AND hit_coll_ID > 0 + GROUP BY hit_date, hit_coll_ID', + 'Aggregate ONLY collection sessions from hit log (hit_agent_type = "browser")' ); + } + if( $type == 'all' || $type == 'coll_api' ) + { // ONLY collection API sessions: + $DB->query( 'INSERT INTO T_hits__aggregate_sessions ( hags_date, hags_coll_ID, hags_count_api ) + SELECT DATE( hit_datetime ) AS hit_date, hit_coll_ID, COUNT( DISTINCT hit_sess_ID ) + FROM T_hitlog + WHERE hit_datetime < '.$DB->quote( $max_aggregate_date ).' + AND hit_type = "api" + AND hit_coll_ID > 0 + GROUP BY hit_date, hit_coll_ID + ON DUPLICATE KEY UPDATE hags_count_api = VALUES( hags_count_api )', + 'Aggregate ONLY collection sessions from hit log (hit_type = "api")' ); + } + if( $type == 'all' || $type == 'all_browser' ) + { // ALL browser sessions: + $DB->query( 'REPLACE INTO T_hits__aggregate_sessions ( hags_date, hags_coll_ID, hags_count_browser ) + SELECT DATE( hit_datetime ) AS hit_date, 0, COUNT( DISTINCT hit_sess_ID ) + FROM T_hitlog + WHERE hit_datetime < '.$DB->quote( $max_aggregate_date ).' + AND hit_agent_type = "browser" + GROUP BY hit_date', + 'Aggregate ALL sessions from hit log (hit_agent_type = "browser")' ); + } + if( $type == 'all' || $type == 'all_api' ) + { // ALL API sessions: + $DB->query( 'INSERT INTO T_hits__aggregate_sessions ( hags_date, hags_coll_ID, hags_count_api ) + SELECT DATE( hit_datetime ) AS hit_date, 0, COUNT( DISTINCT hit_sess_ID ) + FROM T_hitlog + WHERE hit_datetime < '.$DB->quote( $max_aggregate_date ).' + AND hit_type = "api" + GROUP BY hit_date + ON DUPLICATE KEY UPDATE hags_count_api = VALUES( hags_count_api )', + 'Aggregate ALL sessions from hit log (hit_type = "api")' ); + } } diff --git a/inc/sessions/model/_hitlog.funcs.php b/inc/sessions/model/_hitlog.funcs.php index 98d91fe309a..d641e23ad48 100644 --- a/inc/sessions/model/_hitlog.funcs.php +++ b/inc/sessions/model/_hitlog.funcs.php @@ -33,18 +33,18 @@ function hits_results_block( $params = array() ) return; } - global $blog, $sec_ID, $current_User; + global $blog, $sec_ID; if( $blog == 0 ) { - if( ! $current_User->check_perm( 'stats', 'view' ) ) + if( ! check_user_perm( 'stats', 'view' ) ) { // Current user has no permission to view all stats (aggregated stats) return; } } else { - if( ! $current_User->check_perm( 'stats', 'list', false, $blog ) ) + if( ! check_user_perm( 'stats', 'list', false, $blog ) ) { // Current user has no permission to view the stats of the selected blog return; } @@ -1174,8 +1174,7 @@ function stats_goal_hit_extra_params( $ghit_params ) $ItemCache = & get_ItemCache(); if( $Item = & $ItemCache->get_by_ID( intval( $matches[1] ), false, false ) ) { // Display a link to view with current item title - global $current_User; - if( $current_User->check_perm( 'item_post!CURSTATUS', 'edit', false, $Item ) ) + if( check_user_perm( 'item_post!CURSTATUS', 'edit', false, $Item ) ) { // Link to admin view return $Item->get_title( array( 'link_type' => 'admin_view' ) ); } @@ -1199,7 +1198,7 @@ function stats_goal_hit_extra_params( $ghit_params ) */ function display_hits_summary_panel( $diagram_columns = array() ) { - global $ReqURL, $current_User; + global $ReqURL; $hits_summary_mode = get_hits_summary_mode(); @@ -1226,7 +1225,7 @@ function display_hits_summary_panel( $diagram_columns = array() ) display_hits_filter_form( 'filter', $diagram_columns, $hits_summary_mode == 'aggregate' ); } - if( $current_User->check_perm( 'stats', 'edit' ) ) + if( check_user_perm( 'stats', 'edit' ) ) { // Display button to aggregate hits right now only if current user has a permission to edit hits: echo '' @@ -1608,4 +1607,47 @@ function get_hit_full_url( $hit_uri, $hit_coll_ID ) return $hit_host.$hit_uri; } -?> \ No newline at end of file + + +/** + * Get the search engine parameter definitions. + * + * Based on search engine detections YAML list maintained and used by Matomo - {@link https://github.com/matomo-org/searchengine-and-social-list} + * + * @return array of search engine definitions + */ +function get_search_engine_params() +{ + global $search_engine_params, $inc_path; + + if( empty( $search_engine_params ) ) + { + $search_engine_params = array(); + + // Load search engine definitions: + $search_engine_definitions = json_decode( file_get_contents( $inc_path.'_ext/matomo/SearchEngines.json' ) ); + + foreach( $search_engine_definitions as $name => $info ) + { + if( empty( $info ) || !is_array( $info ) ) + { + continue; + } + + foreach( $info as $url_definitions ) + { + $url_definitions = (array) $url_definitions; + foreach( $url_definitions['urls'] as $url ) + { + $search_engine_data = $url_definitions; + unset( $search_engine_data['urls'] ); + $search_engine_data['name'] = $name; + $search_engine_params[$url] = $search_engine_data; + } + } + } + } + + return $search_engine_params; +} +?> diff --git a/inc/sessions/model/_search_engines.php b/inc/sessions/model/_search_engines.php deleted file mode 100644 index 5da1901d727..00000000000 --- a/inc/sessions/model/_search_engines.php +++ /dev/null @@ -1,997 +0,0 @@ - array( SearchEngineName, KeywordParameter, [path containing the keyword], [charset used by the search engine], [search rank parameter]) - * - * NOTE: KeywordParameter may be NULL when search engine supports urls without keyword param like it Google does - * - * The main search engine URL has to be at the top of the list for the given - * search Engine. This serves as the master record so additional URLs - * don't have to duplicate all the information, but can override when needed. - * - * The URL, "example.com", will match "example.com", "m.example.com", - * "www.example.com", and "search.example.com". - * - * For region-specific search engines, the URL, "{}.example.com" will match - * any ISO3166-1 alpha2 country code against "{}". Similarly, "example.{}" - * will match against valid country TLDs, but should be used sparingly to - * avoid false positives. - * - * The charset should be an encoding supported by mbstring. If unspecified, - * we'll assume it's UTF-8. - * Reference: http://www.php.net/manual/en/mbstring.encodings.php - * - * To help us link directly the search engine result page for the keyword, - * specify the third entry in the array using the macro {k} that will - * automatically be replaced by the keyword. - * - * A simple example is: - * 'www.google.com' => array('Google', NULL), - * 'www.google.com' => array('Google', 'q', 'search?q={k}'), - * - * A more complicated example, with an array of possible variable names, custom charset and a serp rank param: - * 'www.baidu.com' => array('Baidu', array('wd', 'word', 'kw'), 's?wd={k}', 'gb2312', 'start'), - * - * Another example using a regular expression to parse the path for keywords: - * 'infospace.com' => array('InfoSpace', array('/dir1\/(pattern)\/dir2/'), '/dir1/{k}/dir2/stuff/'), - */ -$search_engine_params = array( - // 1 - '1.cz' => array('1.cz', 'q', 'index.php?q={k}', 'iso-8859-2'), - - // 123people - 'www.123people.com' => array('123people', array('/s\/([^\/]+)/', 'search_term'), 's/{k}'), - '123people.{}' => array('123people'), - - // 1und1 - 'search.1und1.de' => array('1und1', 'su', 'search/web/?su={k}'), - - // Abacho - 'www.abacho.de' => array('Abacho', 'q', 'suche?q={k}'), - 'www.abacho.com' => array('Abacho'), - 'www.abacho.co.uk' => array('Abacho'), - 'www.se.abacho.com' => array('Abacho'), - 'www.tr.abacho.com' => array('Abacho'), - 'www.abacho.at' => array('Abacho'), - 'www.abacho.fr' => array('Abacho'), - 'www.abacho.es' => array('Abacho'), - 'www.abacho.ch' => array('Abacho'), - 'www.abacho.it' => array('Abacho'), - - // ABCsok - 'abcsok.no' => array('ABCsok', 'q', '?q={k}'), - 'verden.abcsok.no' => array('ABCsok'), - - // Acoon - 'www.acoon.de' => array('Acoon', 'begriff', 'cgi-bin/search.exe?begriff={k}'), - - // Alexa - 'alexa.com' => array('Alexa', 'q', 'search?q={k}'), - 'search.toolbars.alexa.com' => array('Alexa'), - - // Alice Adsl - 'rechercher.aliceadsl.fr' => array('Alice Adsl', 'qs', 'google.pl?qs={k}'), - - // Allesklar - 'www.allesklar.de' => array('Allesklar', 'words', '?words={k}'), - 'www.allesklar.at' => array('Allesklar'), - 'www.allesklar.ch' => array('Allesklar'), - - // AllTheWeb - 'www.alltheweb.com' => array('AllTheWeb', 'q', 'search?q={k}'), - - // All.by - 'all.by' => array('All.by', 'query', 'cgi-bin/search.cgi?mode=by&query={k}'), - - // Altavista - 'www.altavista.com' => array('AltaVista', 'q', 'web/results?q={k}', '', 'b'), - 'search.altavista.com' => array('AltaVista'), - 'listings.altavista.com' => array('AltaVista'), - 'altavista.de' => array('AltaVista'), - 'altavista.fr' => array('AltaVista'), - '{}.altavista.com' => array('AltaVista'), - 'be-nl.altavista.com' => array('AltaVista'), - 'be-fr.altavista.com' => array('AltaVista'), - - // Apollo Latvia - 'apollo.lv/portal/search/' => array('Apollo lv', 'q', '?cof=FORID%3A11&q={k}&search_where=www'), - - // APOLLO7 - 'apollo7.de' => array('Apollo7', 'query', 'a7db/index.php?query={k}&de_sharelook=true&de_bing=true&de_witch=true&de_google=true&de_yahoo=true&de_lycos=true'), - - // AOL - 'search.aol.com' => array('AOL', array('query', 'q', 'userQuery', 'as_q'), 'aol/search?q={k}'), - 'search.aol.{}' => array('AOL'), - 'aol.{}' => array('AOL'), - 'aolsearch.aol.com' => array('AOL'), - 'www.aolrecherche.aol.fr' => array('AOL'), - 'www.aolrecherches.aol.fr' => array('AOL'), - 'www.aolimages.aol.fr' => array('AOL'), - 'aim.search.aol.com' => array('AOL'), - 'www.recherche.aol.fr' => array('AOL'), - 'find.web.aol.com' => array('AOL'), - 'recherche.aol.ca' => array('AOL'), - 'aolsearch.aol.co.uk' => array('AOL'), - 'search.aol.co.uk' => array('AOL'), - 'aolrecherche.aol.fr' => array('AOL'), - 'sucheaol.aol.de' => array('AOL'), - 'suche.aol.de' => array('AOL'), - 'suche.aolsvc.de' => array('AOL'), - 'aolbusqueda.aol.com.mx' => array('AOL'), - 'alicesuche.aol.de' => array('AOL'), - 'alicesuchet.aol.de' => array('AOL'), - 'alicesuche.aol.de' => array('AOL'), - 'suchet2.aol.de' => array('AOL'), - 'search.hp.my.aol.com.au' => array('AOL'), - 'search.hp.my.aol.de' => array('AOL'), - 'search.hp.my.aol.it' => array('AOL'), - 'search-intl.netscape.com' => array('AOL'), - - // Aport - 'sm.aport.ru' => array('Aport', 'r', 'search?r={k}', 'windows-1251', 'p'), - - // Arama - 'arama.com' => array('Arama', 'q', 'search.php3?q={k}'), - - // Arcor - 'www.arcor.de' => array('Arcor', 'Keywords', 'content/searchresult.jsp?Keywords={k}'), - - // Arianna (Libero.it) - 'arianna.libero.it' => array('Arianna', 'query', 'search/abin/integrata.cgi?query={k}'), - 'www.arianna.com' => array('Arianna'), - - // Ask (IAC Search & Media) - 'ask.com' => array('Ask', array('ask', 'q', 'searchfor'), 'web?q={k}'), - 'web.ask.com' => array('Ask'), - 'int.ask.com' => array('Ask'), - 'mws.ask.com' => array('Ask'), - 'images.ask.com' => array('Ask'), - 'images.{}.ask.com' => array('Ask'), - 'ask.reference.com' => array('Ask'), - 'www.askkids.com' => array('Ask'), - 'iwon.ask.com' => array('Ask'), - 'www.ask.co.uk' => array('Ask'), - '{}.ask.com' => array('Ask'), - 'www.qbyrd.com' => array('Ask'), - '{}.qbyrd.com' => array('Ask'), - 'www.search-results.com' => array('Ask'), - '{}.search-results.com' => array('Ask'), - - // Atlas - 'searchatlas.centrum.cz' => array('Atlas', 'q', '?q={k}'), - - // Austronaut - 'www2.austronaut.at' => array('Austronaut', 'q'), - 'www1.austronaut.at' => array('Austronaut'), - - // Babylon (Enhanced by Google) - 'search.babylon.com' => array('Babylon', array('q', '/\/web\/(.*)/'), '?q={k}'), - 'searchassist.babylon.com' => array('Babylon'), - - // Baidu - 'www.baidu.com' => array('Baidu', array('wd', 'word', 'kw'), 's?wd={k}', 'gb2312', 'pn'), - 'www1.baidu.com' => array('Baidu'), - 'zhidao.baidu.com' => array('Baidu'), - 'tieba.baidu.com' => array('Baidu'), - 'news.baidu.com' => array('Baidu'), - 'web.gougou.com' => array('Baidu', 'search', 'search?search={k}'), // uses baidu search - - // Bellnet - 'www.suchmaschine.com' => array('Bellnet', 'suchstr', 'cgi-bin/bellnet.cgi?suchstr={k}'), - - // Biglobe - 'cgi.search.biglobe.ne.jp' => array('Biglobe', 'q', 'cgi-bin/search-st?q={k}'), - - // Bing - 'bing.com' => array('Bing', array('q', 'Q'), 'search?q={k}', '', 'first'), - '{}.bing.com' => array('Bing'), - 'msnbc.msn.com' => array('Bing'), - 'm.bing.com' => array('Bing'), - - // Bing Cache - 'cc.bingj.com' => array('Bing'), - - // Bing Images - 'bing.com/images/search' => array('Bing Images', array('q', 'Q'), '?q={k}'), - '{}.bing.com/images/search' => array('Bing Images'), - - // blekko - 'blekko.com' => array('blekko', array('q', '/\/ws\/(.*)/'), 'ws/{k}'), - - // Blogdigger - 'www.blogdigger.com' => array('Blogdigger', 'q'), - - // Blogpulse - 'www.blogpulse.com' => array('Blogpulse', 'query', 'search?query={k}'), - - // Bluewin - 'search.bluewin.ch' => array('Bluewin', 'searchTerm', '?searchTerm={k}'), - - // Canoe.ca - 'web.canoe.ca' => array('Canoe.ca', 'q', 'search?q={k}'), - - // Centrum - 'search.centrum.cz' => array('Centrum', 'q', '?q={k}'), - 'morfeo.centrum.cz' => array('Centrum'), - - // Charter - 'www.charter.net' => array('Charter', 'q', 'search/index.php?q={k}'), - - // Clix (Enhanced by Google) - 'pesquisa.clix.pt' => array('Clix', 'question', 'resultado.html?in=Mundial&question={k}'), - - // Conduit - 'search.conduit.com' => array('Conduit.com', 'q', 'Results.aspx?q={k}'), - - // Comcast - 'search.comcast.net' => array('Comcast', 'q', '?q={k}'), - - // Compuserve - 'websearch.cs.com' => array('Compuserve.com (Enhanced by Google)', 'query', 'cs/search?query={k}'), - - // Crawler - 'crawler.com' => array('Crawler.com', 'a', 'search/results1.aspx?q={k}'), - - // Cuil - 'www.cuil.com' => array('Cuil', 'q', 'search?q={k}'), - - // Daemon search - 'daemon-search.com' => array('Daemon search', 'q', 'explore/web?q={k}'), - 'my.daemon-search.com' => array('Daemon search'), - - // DasOertliche - 'www.dasoertliche.de' => array('DasOertliche', 'kw'), - - // DasTelefonbuch - 'www1.dastelefonbuch.de' => array('DasTelefonbuch', 'kw'), - - // Daum - 'search.daum.net' => array('Daum', 'q', 'search?q={k}', 'EUC-KR'), - - // Delfi Latvia - 'smart.delfi.lv' => array('Delfi lv', 'q', 'find?q={k}'), - - // Delfi - 'otsing.delfi.ee' => array('Delfi EE', 'q', 'find?q={k}'), - - // Digg - 'digg.com' => array('Digg', 's', 'search?s={k}'), - - // Dir.com - 'fr.dir.com' => array('Dir.com', 'req'), - - // Dmoz - 'dmoz.org' => array('Dmoz', 'search', '', '', 'start'), - 'editors.dmoz.org' => array('Dmoz'), - - // DuckDuckGo - 'duckduckgo.com' => array('DuckDuckGo', 'q', '?q={k}'), - - // Earthlink - 'search.earthlink.net' => array('Earthlink', 'q', 'search?q={k}'), - - // Ecosia (powered by Bing) - 'ecosia.org' => array('Ecosia', 'q', 'search.php?q={k}'), - - // Eniro - 'www.eniro.se' => array('Eniro', array('q', 'search_word'), 'query?q={k}'), - - // Eurip - 'www.eurip.com' => array('Eurip', 'q', 'search/?q={k}'), - - // Euroseek - 'www.euroseek.com' => array('Euroseek', 'string', 'system/search.cgi?string={k}'), - - // Everyclick - 'www.everyclick.com' => array('Everyclick', 'keyword'), - - // Excite - 'search.excite.it' => array('Excite', 'q', 'web/?q={k}'), - 'search.excite.fr' => array('Excite'), - 'search.excite.de' => array('Excite'), - 'search.excite.co.uk' => array('Excite'), - 'search.excite.es' => array('Excite'), - 'search.excite.nl' => array('Excite'), - 'msxml.excite.com' => array('Excite', '/\/[^\/]+\/ws\/results\/[^\/]+\/([^\/]+)/'), - 'www.excite.co.jp' => array('Excite', 'search', 'search.gw?search={k}', 'SHIFT_JIS'), - - // Exalead - 'www.exalead.fr' => array('Exalead', 'q', 'search/results?q={k}'), - 'www.exalead.com' => array('Exalead'), - - // eo - 'eo.st' => array('eo', 'x_query', 'cgi-bin/eolost.cgi?x_query={k}'), - - // Facebook - 'www.facebook.com' => array('Facebook', 'q', 'search/?q={k}'), - - // Fast Browser Search - 'www.fastbrowsersearch.com' => array('Fast Browser Search', 'q', 'results/results.aspx?q={k}'), - - // Francite - 'recherche.francite.com' => array('Francite', 'name'), - - // Fireball - 'www.fireball.de' => array('Fireball', 'q', 'ajax.asp?q={k}'), - - // Firstfind - 'www.firstsfind.com' => array('Firstsfind', 'qry'), - - // Fixsuche - 'www.fixsuche.de' => array('Fixsuche', 'q'), - - // Flix - 'www.flix.de' => array('Flix.de', 'keyword'), - - // Forestle - 'forestle.org' => array('Forestle', 'q', 'search.php?q={k}'), - '{}.forestle.org' => array('Forestle'), - 'forestle.mobi' => array('Forestle'), - - // Free - 'search.free.fr' => array('Free', 'q'), - 'search1-2.free.fr' => array('Free'), - 'search1-1.free.fr' => array('Free'), - - // Freecause - 'search.freecause.com' => array('FreeCause', 'p', '?p={k}'), - - // Freenet - 'suche.freenet.de' => array('Freenet', array('query', 'Keywords'), 'suche/?query={k}'), - - // FriendFeed - 'friendfeed.com' => array('FriendFeed', 'q', 'search?q={k}'), - - // GAIS - 'gais.cs.ccu.edu.tw' => array('GAIS', 'q', 'search.php?q={k}'), - - // Geona - 'geona.net' => array('Geona', 'q', 'search?q={k}'), - - // Gde - 'gde.ru' => array('Gde.ru', 'keywords', '', 'windows-1251'), - - // Gigablast - 'www.gigablast.com' => array('Gigablast', 'q', 'search?q={k}'), - 'dir.gigablast.com' => array('Gigablast (Directory)', 'q'), - - // GMX - 'suche.gmx.net' => array('GMX', 'su', 'search/web/?su={k}'), - - // Gnadenmeer - 'www.gnadenmeer.de' => array('Gnadenmeer', 'keyword'), - - // Goo - 'search.goo.ne.jp' => array('goo', 'MT', 'web.jsp?MT={k}'), - 'ocnsearch.goo.ne.jp' => array('goo'), - - // Google - 'google.com' => array('Google', NULL), - 'google.{}' => array('Google'), - 'www2.google.com' => array('Google'), - 'ipv6.google.com' => array('Google'), - 'go.google.com' => array('Google'), - - // Google vs typo squatters - 'wwwgoogle.com' => array('Google'), - 'wwwgoogle.{}' => array('Google'), - 'gogole.com' => array('Google'), - 'gogole.{}' => array('Google'), - 'gppgle.com' => array('Google'), - 'gppgle.{}' => array('Google'), - 'googel.com' => array('Google'), - 'googel.{}' => array('Google'), - - // Powered by Google - 'search.avg.com' => array('Google'), - 'isearch.avg.com' => array('Google'), - 'www.cnn.com' => array('Google', 'query'), - 'darkoogle.com' => array('Google'), - 'search.darkoogle.com' => array('Google'), - 'search.foxtab.com' => array('Google'), - 'www.gooofullsearch.com' => array('Google', 'Keywords'), - 'search.hiyo.com' => array('Google'), - 'search.incredimail.com' => array('Google'), - 'search1.incredimail.com' => array('Google'), - 'search2.incredimail.com' => array('Google'), - 'search3.incredimail.com' => array('Google'), - 'search4.incredimail.com' => array('Google'), - 'search.sweetim.com' => array('Google'), - 'www.fastweb.it' => array('Google'), - 'search.juno.com' => array('Google', 'query'), - 'searchresults.verizon.com' => array('Google'), - 'homepage.am' => array('Google'), - 'search.homepage.am' => array('Google'), - 'search.alot.com' => array('Google'), - - // Google Earth - // - 2010-09-13: are these redirects now? - 'www.googleearth.de' => array('Google'), - 'www.googleearth.fr' => array('Google'), - - // Google Cache - 'webcache.googleusercontent.com'=> array('Google', '/\/search\?q=cache:[A-Za-z0-9]+:[^+]+([^&]+)/', 'search?q={k}'), - - // Google SSL - 'encrypted.google.com' => array('Google SSL', 'q', 'search?q={k}', '', array('start','cd')), - - // Google Blogsearch - 'blogsearch.google.com' => array('Google Blogsearch', 'q', 'blogsearch?q={k}'), - 'blogsearch.google.{}' => array('Google Blogsearch'), - - // Google Custom Search - 'google.com/cse' => array('Google Custom Search', array('q', 'query')), - 'google.{}/cse' => array('Google Custom Search'), - 'google.com/custom' => array('Google Custom Search'), - 'google.{}/custom' => array('Google Custom Search'), - - // Google Translation - 'translate.google.com' => array('Google Translations', 'q'), - - // Google Images - 'images.google.com' => array('Google Images', 'q', 'images?q={k}'), - 'images.google.{}' => array('Google Images'), - - // Google News - 'news.google.com' => array('Google News', 'q'), - 'news.google.{}' => array('Google News'), - - // Google Shopping - 'google.com/products' => array('Google Shopping', 'q', '?q={k}&tbm=shop'), - 'google.{}/products' => array('Google Shopping'), - - // Google syndicated search - 'googlesyndicatedsearch.com'=> array('Google syndicated search', 'q'), - - // Google Video - 'video.google.com' => array('Google Video', 'q', 'search?q={k}&tbm=vid'), - - // Google Wireless Transcoder - // - does not appear to execute JavaScript - //'google.com/gwt/n' => array('Google Wireless Transcoder'), - - // Goyellow.de - 'www.goyellow.de' => array('GoYellow.de', 'MDN'), - - // Gule Sider - 'www.gulesider.no' => array('Gule Sider', 'q'), - - // HighBeam - 'www.highbeam.com' => array('HighBeam', 'q', 'Search.aspx?q={k}'), - - // Hit-Parade - 'req.hit-parade.com' => array('Hit-Parade', 'p7', 'general/recherche.asp?p7={k}'), - 'class.hit-parade.com' => array('Hit-Parade'), - 'www.hit-parade.com' => array('Hit-Parade'), - - // Holmes.ge - 'holmes.ge' => array('Holmes', 'q', 'search.htm?q={k}'), - - // Hooseek.com - 'www.hooseek.com' => array('Hooseek', 'recherche', 'web?recherche={k}'), - - // Hotbot - 'www.hotbot.com' => array('Hotbot', 'query'), - - // Icerocket - 'blogs.icerocket.com' => array('Icerocket', 'q', 'search?q={k}'), - - // ICQ - 'www.icq.com' => array('ICQ', 'q', 'search/results.php?q={k}', '', 'start'), - 'search.icq.com' => array('ICQ'), - - // Ilse - 'www.ilse.nl' => array('Ilse NL', 'search_for', '?search_for={k}'), - - // InfoSpace (and related web properties) - 'infospace.com' => array('InfoSpace', '/\/[^\/]+\/ws\/results\/[^\/]+\/([^\/]+)/', 'ispace/ws/results/Web/{k}/1/1/content-top-left/Relevance/'), - 'dogpile.com' => array('InfoSpace'), - 'nbci.dogpile.com' => array('InfoSpace'), - 'search.nation.com' => array('InfoSpace'), - 'search.go2net.com' => array('InfoSpace'), - 'metacrawler.com' => array('InfoSpace'), - 'webfetch.com' => array('InfoSpace'), - 'webcrawler.com' => array('InfoSpace'), - 'search.dogreatgood.com' => array('InfoSpace'), - - // Powered by InfoSpace - 'isearch.babylon.com' => array('InfoSpace', 'q'), - 'start.facemoods.com' => array('InfoSpace', 's'), - 'search.magentic.com' => array('InfoSpace', 'q'), - 'search.searchcompletion.com'=> array('InfoSpace', 'q'), - - /* - * Other InfoSpace powered metasearches are handled in Piwik_Common::extractSearchEngineInformationFromUrl() - * - * This includes sites such as: - * - search.kiwee.com - * - ws.copernic.com - * - result.iminent.com - */ - - // Interia - 'www.google.interia.pl' => array('Interia', 'q', 'szukaj?q={k}'), - - // I-play - 'start.iplay.com' => array('I-play', 'q', 'searchresults.aspx?q={k}'), - - // Ixquick - 'ixquick.com' => array('Ixquick', 'query', '', '', 'startat'), - 'www.eu.ixquick.com' => array('Ixquick'), - 'ixquick.de' => array('Ixquick'), - 'www.ixquick.de' => array('Ixquick'), - 'us.ixquick.com' => array('Ixquick'), - 's1.us.ixquick.com' => array('Ixquick'), - 's2.us.ixquick.com' => array('Ixquick'), - 's3.us.ixquick.com' => array('Ixquick'), - 's4.us.ixquick.com' => array('Ixquick'), - 's5.us.ixquick.com' => array('Ixquick'), - 'eu.ixquick.com' => array('Ixquick'), - 's8-eu.ixquick.com' => array('Ixquick'), - 's1-eu.ixquick.de' => array('Ixquick'), - - // Jyxo - 'jyxo.1188.cz' => array('Jyxo', 'q', 's?q={k}'), - - // Jungle Spider - 'www.jungle-spider.de' => array('Jungle Spider', 'q'), - - // Jungle key - 'junglekey.com' => array('Jungle Key', 'query', 'search.php?query={k}&type=web&lang=en'), - 'junglekey.fr' => array('Jungle Key'), - - // Kataweb - 'www.kataweb.it' => array('Kataweb', 'q'), - - // Kvasir - 'www.kvasir.no' => array('Kvasir', 'q', 'alle?q={k}'), - - // Latne - 'www.latne.lv' => array('Latne', 'q', 'siets.php?q={k}'), - - // La Toile Du Quebec via Google - 'www.toile.com' => array('La Toile Du Quebec (Google)', 'q', 'search?q={k}'), - 'web.toile.com' => array('La Toile Du Quebec (Google)'), - - // LiveInternet.ru - 'www.liveinternet.ru' => array('LiveInternet.ru', 'q', 'q/?q={k}'), - - // LiveTool - 'search.livetool.ru' => array('LiveTool', 'text', '', array('utf-8','windows-1251'), 'text'), - - // Looksmart - 'www.looksmart.com' => array('Looksmart', 'key'), - - // Lo.st (Enhanced by Google) - 'lo.st' => array('Lo.st', 'x_query', 'cgi-bin/eolost.cgi?x_query={k}'), - - // Lycos - 'search.lycos.com' => array('Lycos', 'query', '?query={k}', '', 'page2'), - 'lycos.{}' => array('Lycos'), - - // maailm.com - 'www.maailm.com' => array('maailm.com', 'tekst'), - - // Mail.ru - 'go.mail.ru' => array('Mail.ru', 'q', 'search?q={k}', array('utf-8','windows-1251'), 'sf'), - 'search.list.mail.ru' => array('Mail.ru'), - 'searchru.icq.com' => array('Mail.ru'), // It's powered my go.mail.ru search engine! - - // Mamma - 'www.mamma.com' => array('Mamma', 'query', 'result.php?q={k}'), - 'mamma75.mamma.com' => array('Mamma'), - - // Meta - 'meta.ua' => array('Meta.ua', 'q', 'search.asp?q={k}'), - - // MetaCrawler.de - 's1.metacrawler.de' => array('MetaCrawler DE', 'qry', '?qry={k}'), - 's2.metacrawler.de' => array('MetaCrawler DE'), - 's3.metacrawler.de' => array('MetaCrawler DE'), - - // Metager - 'meta.rrzn.uni-hannover.de' => array('Metager', 'eingabe', 'meta/cgi-bin/meta.ger1?eingabe={k}'), - 'www.metager.de' => array('Metager'), - - // Metager2 - 'metager2.de' => array('Metager2', 'q', 'search/index.php?q={k}'), - - // Meinestadt - 'www.meinestadt.de' => array('Meinestadt.de', 'words'), - - // Mister Wong - 'www.mister-wong.com' => array('Mister Wong', 'keywords', 'search/?keywords={k}'), - 'www.mister-wong.de' => array('Mister Wong'), - - // Monstercrawler - 'www.monstercrawler.com' => array('Monstercrawler', 'qry'), - - // Mozbot - 'www.mozbot.fr' => array('mozbot', 'q', 'results.php?q={k}'), - 'www.mozbot.co.uk' => array('mozbot'), - 'www.mozbot.com' => array('mozbot'), - - // El Mundo - 'ariadna.elmundo.es' => array('El Mundo', 'q'), - - // Mynet - 'arama.mynet.com' => array('Mynet', 'query', 'result?query={k}'), - - // MySpace - 'searchservice.myspace.com' => array('MySpace', 'qry', 'index.cfm?fuseaction=sitesearch.results&type=Web&qry={k}'), - - // MySearch / MyWay / MyWebSearch (default: powered by Ask.com) - 'www.mysearch.com' => array('MyWebSearch', array('searchfor', 'searchFor'), 'search/Ajmain.jhtml?searchfor={k}', '', 'pn'), - 'ms114.mysearch.com' => array('MyWebSearch'), - 'ms146.mysearch.com' => array('MyWebSearch'), - 'kf.mysearch.myway.com' => array('MyWebSearch'), - 'ki.mysearch.myway.com' => array('MyWebSearch'), - 'search.myway.com' => array('MyWebSearch'), - 'search.mywebsearch.com' => array('MyWebSearch'), - - - // Najdi - 'www.najdi.si' => array('Najdi.si', 'q', 'search.jsp?q={k}'), - - // Nate - 'search.nate.com' => array('Nate', 'q', 'search/all.html?q={k}', 'EUC-KR'), - - // Naver - 'search.naver.com' => array('Naver', 'query', 'search.naver?query={k}', 'EUC-KR'), - - // Needtofind - 'ko.search.need2find.com' => array('Needtofind', 'searchfor', 'search/AJmain.jhtml?searchfor={k}'), - - // Neti - 'www.neti.ee' => array('Neti', 'query', 'cgi-bin/otsing?query={k}', 'iso-8859-1'), - - // Nifty - 'search.nifty.com' => array('Nifty', 'q', 'websearch/search?q={k}'), - - // Nigma - 'nigma.ru' => array('Nigma.ru', 's', 'index.php?s={k}', '', 'startpos'), - 'www.nigma.ru' => array('Nigma.ru'), - - // Onet - 'szukaj.onet.pl' => array('Onet.pl', 'qt', 'query.html?qt={k}'), - - // Online.no - 'online.no' => array('Online.no', 'q', 'google/index.jsp?q={k}'), - - // OpenDNS - 'guide.opendns.com' => array('OpenDNS', 'q', 'main?q={k}'), - - // Opplysningen 1881 - 'www.1881.no' => array('Opplysningen 1881', 'Query', 'Multi/?Query={k}'), - - // Orange - 'busca.orange.es' => array('Orange', 'q', 'search?q={k}'), - - // Paperball - 'www.paperball.de' => array('Paperball', 'q', 'suche/s/?q={k}'), - - // PeoplePC - 'search.peoplepc.com' => array('PeoplePC', 'q', 'search?q={k}'), - - // Picsearch - 'www.picsearch.com' => array('Picsearch', 'q', 'index.cgi?q={k}'), - - // Plazoo - 'www.plazoo.com' => array('Plazoo', 'q'), - - // Poisk.Ru - 'poisk.ru' => array('Poisk.Ru', 'text', 'cgi-bin/poisk?text={k}', 'windows-1251'), - - // QIP - 'search.qip.ru' => array('QIP.ru', 'query', 'search?query={k}'), - 'magna.qip.ru' => array('QIP.ru', 'q', '', 'utf-8', 'page'), - - // Qualigo - 'www.qualigo.at' => array('Qualigo', 'q'), - 'www.qualigo.ch' => array('Qualigo'), - 'www.qualigo.de' => array('Qualigo'), - 'www.qualigo.nl' => array('Qualigo'), - - // Rakuten - 'websearch.rakuten.co.jp' => array('Rakuten', 'qt', 'WebIS?qt={k}'), - - // Rambler - 'rambler.ru' => array('Rambler', array('query', 'words'), 'search?query={k}'), - 'nova.rambler.ru' => array('Rambler'), - 'news.rambler.ru' => array('Rambler'), - 'images.rambler.ru' => array('Rambler'), - 'm.rambler.ru' => array('Rambler'), - - // Reddit - 'www.reddit.com' => array('Reddit', 'q', '', 'utf-8', 'count'), - - // RPMFind - 'rpmfind.net' => array('rpmfind', 'query', 'linux/rpm2html/search.php?query={k}'), - 'fr2.rpmfind.net' => array('rpmfind'), - - // Road Runner Search - 'search.rr.com' => array('Road Runner', 'q', '?q={k}', '', 'offset'), - - // Sapo - 'pesquisa.sapo.pt' => array('Sapo', 'q', '?q={k}'), - - // scour.com - 'scour.com' => array('Scour.com', '/search\/[^\/]+\/(.*)/', 'search/web/{k}'), - - // Search.com - 'www.search.com' => array('Search.com', 'q', 'search?q={k}'), - - // Search.ch - 'www.search.ch' => array('Search.ch', 'q', '?q={k}'), - - // Search-results.com - 'www.search-results.com' => array('Search-results.com', 'q'), - - // Searchalot - 'searchalot.com' => array('Searchalot', 'q', '?q={k}'), - - // SearchCanvas - 'www.searchcanvas.com' => array('SearchCanvas', 'q', 'web?q={k}'), - - // Search.ukr.net - 'search.ukr.net' => array('search.ukr.net', 'search_query'), - - // Searchy - 'www.searchy.co.uk' => array('Searchy', 'q', 'index.html?q={k}'), - - // Setooz - // 2010-09-13: the mismatches are because subdomains are language codes - // (not country codes) - 'bg.setooz.com' => array('Setooz', 'query', 'search?query={k}', '', 'pager.offset'), - 'da.setooz.com' => array('Setooz'), - 'el.setooz.com' => array('Setooz'), - 'fa.setooz.com' => array('Setooz'), - 'ur.setooz.com' => array('Setooz'), - '{}.setooz.com' => array('Setooz'), - - // Seznam - 'search.seznam.cz' => array('Seznam', 'q', '?q={k}'), - - // Sharelook - 'www.sharelook.fr' => array('Sharelook', 'keyword'), - - // Skynet - 'www.skynet.be' => array('Skynet', 'q', 'services/recherche/google?q={k}'), - - // Sogou - 'www.sogou.com' => array('Sogou', 'query', 'web?query={k}'), - - // soso.com - 'www.soso.com' => array('Soso', 'w', 'q?w={k}', 'gb2312'), - - // Startpagina - 'startgoogle.startpagina.nl'=> array('Startpagina (Google)', 'q', '?q={k}'), - - // Suche.info - 'suche.info' => array('Suche.info', 'Keywords', 'suche.php?Keywords={k}'), - - // Suchmaschine.com - 'www.suchmaschine.com' => array('Suchmaschine.com', 'suchstr', 'cgi-bin/wo.cgi?suchstr={k}'), - - // Suchnase - 'www.suchnase.de' => array('Suchnase', 'q'), - - // TalkTalk - 'www.talktalk.co.uk' => array('TalkTalk', 'query', 'search/results.html?query={k}'), - - // Technorati - 'technorati.com' => array('Technorati', 'q', 'search?return=sites&authority=all&q={k}'), - - // Teoma - 'www.teoma.com' => array('Teoma', 'q', 'web?q={k}'), - - // Terra -- referer does not contain search phrase (keywords) - 'buscador.terra.es' => array('Terra', 'query', 'Default.aspx?source=Search&query={k}'), - 'buscador.terra.cl' => array('Terra'), - 'buscador.terra.com.br' => array('Terra'), - - // Tiscali - 'search.tiscali.it' => array('Tiscali', array('q', 'key'), '?q={k}'), - 'search-dyn.tiscali.it' => array('Tiscali'), - 'hledani.tiscali.cz' => array('Tiscali', 'query'), - - // Tixuma - 'www.tixuma.de' => array('Tixuma', 'sc', 'index.php?mp=search&stp=&sc={k}&tg=0'), - - // T-Online - 'suche.t-online.de' => array('T-Online', 'q', 'fast-cgi/tsc?mandant=toi&context=internet-tab&q={k}'), - 'brisbane.t-online.de' => array('T-Online'), - 'navigationshilfe.t-online.de'=> array('T-Online', 'q', 'dtag/dns/results?mode=search_top&q={k}'), - - // Toolbarhome - 'www.toolbarhome.com' => array('Toolbarhome', 'q', 'search.aspx?q={k}'), - - 'vshare.toolbarhome.com' => array('Toolbarhome'), - - // Top-page.ru - 'www.top-page.ru' => array('Top-page.ru', array('q', 'query'), '', array('utf-8','windows-1251'), array('page', 'start') ), - - // Trouvez.com - 'www.trouvez.com' => array('Trouvez.com', 'query'), - - // TrovaRapido - 'www.trovarapido.com' => array('TrovaRapido', 'q', 'result.php?q={k}'), - - // Trusted-Search - 'www.trusted--search.com' => array('Trusted Search', 'w', 'search?w={k}'), - - // Tut.by - 'search.tut.by' => array('Tut.by', 'query', 'query?w={k}', array('utf-8','windows-1251') ), - - // Twingly - 'www.twingly.com' => array('Twingly', 'q', 'search?q={k}'), - - // URL.ORGanzier - 'www.url.org' => array('URL.ORGanzier', 'q', '?l=de&q={k}'), - - // Vinden - 'www.vinden.nl' => array('Vinden', 'q', '?q={k}'), - - // Vindex - 'www.vindex.nl' => array('Vindex', 'search_for', '/web?search_for={k}'), - 'search.vindex.nl' => array('Vindex'), - - // Virgilio - 'ricerca.virgilio.it' => array('Virgilio', 'qs', 'ricerca?qs={k}', '', 'offset'), - 'ricercaimmagini.virgilio.it'=> array('Virgilio'), - 'ricercavideo.virgilio.it' => array('Virgilio'), - 'ricercanews.virgilio.it' => array('Virgilio'), - 'mobile.virgilio.it' => array('Virgilio', 'qrs'), - - // Voila - 'search.ke.voila.fr' => array('Voila', 'rdata', 'S/voila?rdata={k}'), - 'www.lemoteur.fr' => array('Voila'), // uses voila search - - // Volny - 'web.volny.cz' => array('Volny', 'search', 'fulltext/?search={k}', 'windows-1250'), - - // Walhello - 'www.walhello.info' => array('Walhello', 'key', 'search?key={k}'), - 'www.walhello.com' => array('Walhello'), - 'www.walhello.de' => array('Walhello'), - 'www.walhello.nl' => array('Walhello'), - - // Web.de - 'suche.web.de' => array('Web.de', 'su', 'search/web/?su={k}'), - - // Web.nl - 'www.web.nl' => array('Web.nl', 'zoekwoord'), - - // Webalta.ru - 'webalta.ru' => array('Webalta.ru', 'q', 'search?q={k}'), - - // Weborama - 'www.weborama.fr' => array('weborama', 'QUERY'), - - // WebSearch - 'www.websearch.com' => array('WebSearch', array('qkw', 'q'), 'search/results2.aspx?q={k}'), - - // Wedoo - // 2011-02-15 - keyword no longer appears to be in Referer URL; candidate for removal? - 'fr.wedoo.com' => array('Wedoo', 'keyword'), - 'en.wedoo.com' => array('Wedoo'), - 'es.wedoo.com' => array('Wedoo'), - - // Winamp (Enhanced by Google) - 'search.winamp.com' => array('Winamp', 'q', 'search/search?q={k}'), - - // Witch - 'www.witch.de' => array('Witch', 'search', 'search-result.php?cn=0&search={k}'), - - // Wirtualna Polska - 'szukaj.wp.pl' => array('Wirtualna Polska', 'szukaj', 'http://szukaj.wp.pl/szukaj.html?szukaj={k}', 'ISO-8859-2', 'offset'), - - // WWW - 'search.www.ee' => array('www varav', 'query'), - - // X-recherche - 'www.x-recherche.com' => array('X-Recherche', 'MOTS', 'cgi-bin/websearch?MOTS={k}'), - - // Yahoo - 'search.yahoo.com' => array('Yahoo!', array('p', 'q'), 'search?p={k}', '', 'b'), - 'yahoo.com' => array('Yahoo!'), - 'yahoo.{}' => array('Yahoo!'), - 'm.yahoo.{}' => array('Yahoo!'), - '{}.m2.yahoo.{}' => array('Yahoo!'), - '{}.search.yahoo.com' => array('Yahoo!'), - 'cade.search.yahoo.com' => array('Yahoo!'), - 'espanol.search.yahoo.com' => array('Yahoo!'), - 'qc.search.yahoo.com' => array('Yahoo!'), - '{}.yahoo.com' => array('Yahoo!'), - 'cade.yahoo.com' => array('Yahoo!'), - 'espanol.yahoo.com' => array('Yahoo!'), - 'qc.yahoo.com' => array('Yahoo!'), - '{}.yhs.search.yahoo.com' => array('Yahoo!'), - 'one.cn.yahoo.com' => array('Yahoo!'), - 'siteexplorer.search.yahoo.com' => array('Yahoo!'), - - // Powered by Yahoo APIs - 'www.cercato.it' => array('Yahoo!', 'q'), - 'search.offerbox.com' => array('Yahoo!', 'q'), - - // Powered by Yahoo! Search Marketing (Overture) - 'ys.mirostart.com' => array('Yahoo!', 'q'), - - // Yahoo! Directory - 'search.yahoo.com/search/dir' => array('Yahoo! Directory', 'p', '?p={k}'), - //'{}.dir.yahoo.com' => array('Yahoo! Directory'), - - // Yahoo! Images - 'images.search.yahoo.com' => array('Yahoo! Images', 'p', 'search/images?p={k}'), - '{}.images.search.yahoo.com'=> array('Yahoo! Images'), - 'cade.images.search.yahoo.com'=> array('Yahoo! Images'), - 'espanol.images.search.yahoo.com'=> array('Yahoo! Images'), - 'qc.images.search.yahoo.com'=> array('Yahoo! Images'), - 'images.yahoo.com' => array('Yahoo! Images'), - '{}.images.yahoo.com' => array('Yahoo! Images'), - 'cade.images.yahoo.com' => array('Yahoo! Images'), - 'espanol.images.yahoo.com' => array('Yahoo! Images'), - 'qc.images.yahoo.com' => array('Yahoo! Images'), - - // Yam - 'search.yam.com' => array('Yam', 'k', 'Search/Web/?SearchType=web&k={k}'), - - // Yandex - 'yandex.com' => array('Yandex', array('text', 'q', 'query'), 'yandsearch?text={k}', array('utf-8','windows-1251'), 'p'), - 'yandex.{}' => array('Yandex'), - 'images.yandex.{}' => array('Yandex'), - 'hghltd.yandex.{}' => array('Yandex'), - 'yaca.yandex.{}' => array('Yandex'), - - // Powered by Yandex - 'search.i.ua' => array('Yandex'), - - // Yasni - 'www.yasni.de' => array('Yasni', 'query'), - 'www.yasni.com' => array('Yasni'), - 'www.yasni.co.uk' => array('Yasni'), - 'www.yasni.ch' => array('Yasni'), - 'www.yasni.at' => array('Yasni'), - - // Yellowmap - 'yellowmap.de' => array('Yellowmap', ' '), - - // Yippy - 'search.yippy.com' => array('Yippy', 'query', 'search?query={k}'), - - // YouGoo - 'www.yougoo.fr' => array('YouGoo', 'q', '?cx=search&q={k}'), - - // Zapmeta - 'www.zapmeta.com' => array('Zapmeta', array('q', 'query'), '?q={k}'), - 'www.zapmeta.nl' => array('Zapmeta'), - 'www.zapmeta.de' => array('Zapmeta'), - 'uk.zapmeta.com' => array('Zapmeta'), - - // Zoek - 'www3.zoek.nl' => array('Zoek', 'q'), - - // Zhongsou - 'p.zhongsou.com' => array('Zhongsou', 'w', 'p?w={k}'), - - // Zoeken - 'www.zoeken.nl' => array('Zoeken', 'q', '?q={k}'), - - // Zoohoo - 'zoohoo.cz' => array('Zoohoo', 'q', '?q={k}', 'windows-1250'), - - // Zoznam - 'www.zoznam.sk' => array('Zoznam', 's', 'hladaj.fcgi?s={k}&co=svet'), -); - -?> \ No newline at end of file diff --git a/inc/sessions/model/_session.class.php b/inc/sessions/model/_session.class.php index 598eb5c205f..f7a3f0420d1 100644 --- a/inc/sessions/model/_session.class.php +++ b/inc/sessions/model/_session.class.php @@ -92,26 +92,53 @@ class Session /** * Constructor * - * If valid session cookie received: pull session from DB + * If valid session cookie received or param session ID is provided: pull session from DB * Otherwise, INSERT a session into DB + * + * @param integer Session ID */ - function __construct() + function __construct( $session_ID = NULL ) { - global $DB, $Debuglog, $current_User, $localtimenow, $Messages, $Settings, $UserSettings; + global $DB, $Debuglog, $localtimenow, $Messages, $Settings, $UserSettings; global $Hit; global $cookie_session, $cookie_expires; $Debuglog->add( 'Session: cookie_domain='.get_cookie_domain(), 'request' ); $Debuglog->add( 'Session: cookie_path='.get_cookie_path(), 'request' ); - $session_cookie = param_cookie( $cookie_session, 'string', '' ); - if( empty( $session_cookie ) ) - { - $Debuglog->add( 'Session: No session cookie received.', 'request' ); + $timeout_sessions = NULL; + if( $this->user_ID != NULL ) + { // User is not anonymous, get custom session timeout (may return NULL): + $timeout_sessions = $UserSettings->get( 'timeout_sessions', $this->user_ID ); + } + if( empty( $timeout_sessions ) ) + { // User is anonymous or has no custom session timeout. So, we use default session timeout: + $timeout_sessions = $Settings->get( 'timeout_sessions' ); + } + + if( $session_ID !== NULL ) + { // Get Session by requested ID: + $Debuglog->add( 'Session: ID='.$session_ID, 'request' ); + + $session_SQL = new SQL( 'Get session data by ID#'.$session_ID ); + $session_SQL->SELECT( 'sess_ID, sess_key, sess_data, sess_user_ID, sess_start_ts, sess_lastseen_ts, sess_device' ); + $session_SQL->FROM( 'T_sessions' ); + $session_SQL->WHERE( 'sess_ID = '.$DB->quote( $session_ID ) ); + $session_SQL->WHERE_and( 'UNIX_TIMESTAMP(sess_lastseen_ts) > '.( $localtimenow - $timeout_sessions ) ); + $row = $DB->get_row( $session_SQL ); + if( empty( $row ) ) + { + $Debuglog->add( 'Session: Session by ID is invalid!', 'request' ); + } } else - { // session ID sent by cookie - if( ! preg_match( '~^(\d+)_(\w+)$~', $session_cookie, $match ) ) + { // Get Session from cookie data ID + key: + $session_cookie = param_cookie( $cookie_session, 'string', '' ); + if( empty( $session_cookie ) ) + { + $Debuglog->add( 'Session: No session cookie received.', 'request' ); + } + elseif( ! preg_match( '~^(\d+)_(\w+)$~', $session_cookie, $match ) ) { $Debuglog->add( 'Session: Invalid session cookie format!', 'request' ); } @@ -122,17 +149,6 @@ function __construct() $Debuglog->add( 'Session: Session ID received from cookie: '.$session_id_by_cookie, 'request' ); - $timeout_sessions = NULL; - if( $this->user_ID != NULL ) - { // User is not anonymous, get custom session timeout (may return NULL): - $timeout_sessions = $UserSettings->get( 'timeout_sessions', $this->user_ID ); - } - - if( empty( $timeout_sessions ) ) - { // User is anonymous or has no custom session timeout. So, we use default session timeout: - $timeout_sessions = $Settings->get('timeout_sessions'); - } - $row = $DB->get_row( ' SELECT sess_ID, sess_key, sess_data, sess_user_ID, sess_start_ts, sess_lastseen_ts, sess_device FROM T_sessions @@ -143,8 +159,11 @@ function __construct() { $Debuglog->add( 'Session: Session ID/key combination is invalid!', 'request' ); } - else - { // ID + key are valid: load data + } + } + + if( ! empty( $row ) ) + { // Load session data if row is found in DB: $Debuglog->add( 'Session: Session ID is valid.', 'request' ); $this->ID = $row->sess_ID; $this->key = $row->sess_key; @@ -204,8 +223,6 @@ function __construct() } } } - } - } if( $this->ID ) @@ -215,8 +232,9 @@ function __construct() $this->session_needs_save( true ); } } - else - { // create a new session! : + elseif( $session_ID === NULL ) + { // Create a new session! Only for session from cookie: + // Do NOT create new session on request by ID! $this->key = generate_random_key( 32 ); // Detect user device diff --git a/inc/sessions/stats.ctrl.php b/inc/sessions/stats.ctrl.php index 64a086b4d1c..b5c0f22d3ed 100644 --- a/inc/sessions/stats.ctrl.php +++ b/inc/sessions/stats.ctrl.php @@ -16,11 +16,6 @@ load_class('sessions/model/_hitlist.class.php', 'Hitlist' ); load_funcs('sessions/model/_hitlog.funcs.php'); -/** - * @var User - */ -global $current_User; - global $collections_Module, $DB; param_action(); @@ -28,11 +23,11 @@ $activate_collection_toolbar = true; // Do we have permission to view all stats (aggregated stats) ? -$perm_view_all = $current_User->check_perm( 'stats', 'view' ); +$perm_view_all = check_user_perm( 'stats', 'view' ); // Section ID: param( 'sec_ID', 'integer', 0, true ); -if( ! $perm_view_all && ! $current_User->check_perm( 'section', 'view', false, $sec_ID ) ) +if( ! $perm_view_all && ! check_user_perm( 'section', 'view', false, $sec_ID ) ) { forget_param( 'sec_ID' ); unset( $sec_ID ); @@ -53,12 +48,12 @@ param( 'action', 'string' ); -if( $tab == 'domains' && $current_User->check_perm( 'stats', 'edit' ) ) +if( $tab == 'domains' && check_user_perm( 'stats', 'edit' ) ) { - require_js( 'jquery/jquery.jeditable.js', 'rsc_url' ); + require_js_defer( 'customized:jquery/jeditable/jquery.jeditable.js', 'rsc_url' ); } -if( ( $blog == 0 && empty( $sec_ID ) ) || ! $current_User->check_perm( 'stats', 'list', false, $blog ) ) +if( ( $blog == 0 && empty( $sec_ID ) ) || ! check_user_perm( 'stats', 'list', false, $blog ) ) { if( ! $perm_view_all && isset( $collections_Module ) ) { // Find a blog we can view stats for: @@ -76,13 +71,13 @@ } // Check permission to view current blog -$current_User->check_perm( 'stats', 'list', true, $blog ); +check_user_perm( 'stats', 'list', true, $blog ); switch( $action ) { case 'changetype': // Change the type of a hit // Check permission: - $current_User->check_perm( 'stats', 'edit', true ); + check_user_perm( 'stats', 'edit', true ); param( 'hit_ID', 'integer', true ); // Required! param( 'new_hit_type', 'string', true ); // Required! @@ -97,7 +92,7 @@ $Session->assert_received_crumb( 'stats' ); // Check permission: - $current_User->check_perm( 'stats', 'edit', true ); + check_user_perm( 'stats', 'edit', true ); param( 'date', 'integer', true ); // Required! if( $r = Hitlist::prune( $date ) ) @@ -115,7 +110,7 @@ case 'reset_counters': - $current_User->check_perm( 'stats', 'edit', true ); + check_user_perm( 'stats', 'edit', true ); $sql = 'UPDATE T_track__keyphrase SET keyp_count_refered_searches = 0, @@ -130,7 +125,7 @@ $Session->assert_received_crumb( 'statssettings' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Hit & Session logs $Settings->set( 'log_public_hits', param( 'log_public_hits', 'integer', 0 ) ); @@ -160,7 +155,7 @@ // Display form to create new domain // Check permission: - $current_User->check_perm( 'stats', 'edit', true ); + check_user_perm( 'stats', 'edit', true ); if( $action == 'domain_new' ) { // New Domain @@ -190,7 +185,7 @@ $Session->assert_received_crumb( 'domain' ); // Check permission: - $current_User->check_perm( 'stats', 'edit', true ); + check_user_perm( 'stats', 'edit', true ); param( 'dom_ID', 'integer', 0, true ); if( empty( $dom_ID ) ) @@ -243,7 +238,7 @@ $Session->assert_received_crumb( 'domain' ); // Check permission: - $current_User->check_perm( 'stats', 'edit', true ); + check_user_perm( 'stats', 'edit', true ); param( 'dom_ID', 'integer', 0, true ); $DomainCache = & get_DomainCache(); @@ -275,7 +270,7 @@ $Session->assert_received_crumb( 'aggregate' ); // Check permission: - $current_User->check_perm( 'stats', 'edit', true ); + check_user_perm( 'stats', 'edit', true ); // Do the aggregations: Hitlist::aggregate_hits(); @@ -592,7 +587,7 @@ if( $tab == 'domains' ) { // Load jquery UI to highlight cell on change domain type - require_js( '#jqueryUI#' ); + require_js_defer( '#jqueryUI#' ); } if( in_array( $tab , array( 'hits', 'other', 'referers' ) ) || diff --git a/inc/sessions/views/_goal_hitsummary.view.php b/inc/sessions/views/_goal_hitsummary.view.php index 3254a3dc380..97c0e89abed 100644 --- a/inc/sessions/views/_goal_hitsummary.view.php +++ b/inc/sessions/views/_goal_hitsummary.view.php @@ -182,7 +182,7 @@ function filter_goal_hitsummary( & $Form ) $Table->display_col_start(); echo $day; - if( $is_live_mode && $current_User->check_perm( 'stats', 'edit' ) ) + if( $is_live_mode && check_user_perm( 'stats', 'edit' ) ) { // Display a link to prune goal hits only for live data and if current user has a permission: echo action_icon( T_('Prune goal hits for this date!'), 'delete', url_add_param( $admin_url, 'ctrl=goals&action=prune&date='.strtotime( $day ).'&blog='.$blog.'&'.url_crumb( 'goals' ) ) ); } diff --git a/inc/sessions/views/_stats_api.view.php b/inc/sessions/views/_stats_api.view.php index a57dd932663..d538a45d6e6 100644 --- a/inc/sessions/views/_stats_api.view.php +++ b/inc/sessions/views/_stats_api.view.php @@ -115,7 +115,7 @@ check_perm( 'stats', 'edit' ) ) + if( $is_live_mode && check_user_perm( 'stats', 'edit' ) ) { // Display a link to prune hits only for live data and if current user has a permission: echo action_icon( T_('Prune hits for this date!'), 'delete', url_add_param( $admin_url, 'ctrl=stats&action=prune&date='.$last_date.'&show=summary'.$section_params.'&'.url_crumb('stats') ) ); } @@ -176,7 +176,7 @@ check_perm( 'stats', 'edit' ) ) + if( $is_live_mode && check_user_perm( 'stats', 'edit' ) ) { // Display a link to prune hits only for live data and if current user has a permission: echo action_icon( T_('Prune hits for this date!'), 'delete', url_add_param( $admin_url, 'ctrl=stats&action=prune&date='.$last_date.'&show=summary'.$section_params.'&'.url_crumb('stats') ) ); } diff --git a/inc/sessions/views/_stats_browserhits.view.php b/inc/sessions/views/_stats_browserhits.view.php index d0805c8a2e5..d09ad8251f7 100644 --- a/inc/sessions/views/_stats_browserhits.view.php +++ b/inc/sessions/views/_stats_browserhits.view.php @@ -117,7 +117,7 @@ check_perm( 'stats', 'edit' ) ) + if( $is_live_mode && check_user_perm( 'stats', 'edit' ) ) { // Display a link to prune hits only for live data and if current user has a permission: echo action_icon( T_('Prune hits for this date!'), 'delete', url_add_param( $admin_url, 'ctrl=stats&action=prune&date='.$last_date.'&show=summary'.$section_params.'&'.url_crumb('stats') ) ); } @@ -180,7 +180,7 @@ check_perm( 'stats', 'edit' ) ) + if( $is_live_mode && check_user_perm( 'stats', 'edit' ) ) { // Display a link to prune hits only for live data and if current user has a permission: echo action_icon( T_('Prune hits for this date!'), 'delete', url_add_param( $admin_url, 'ctrl=stats&action=prune&date='.$last_date.'&show=summary'.$section_params.'&'.url_crumb('stats') ) ); } diff --git a/inc/sessions/views/_stats_goalcats.view.php b/inc/sessions/views/_stats_goalcats.view.php index 758a61ce783..07d699503d1 100644 --- a/inc/sessions/views/_stats_goalcats.view.php +++ b/inc/sessions/views/_stats_goalcats.view.php @@ -16,7 +16,7 @@ global $blog, $admin_url, $rsc_url; global $Session; -$perm_options_edit = $current_User->check_perm( 'options', 'edit', false ); +$perm_options_edit = check_user_perm( 'options', 'edit', false ); /** * View funcs diff --git a/inc/sessions/views/_stats_goals.view.php b/inc/sessions/views/_stats_goals.view.php index dd3c4bc457a..e70a6ec4b86 100644 --- a/inc/sessions/views/_stats_goals.view.php +++ b/inc/sessions/views/_stats_goals.view.php @@ -16,7 +16,7 @@ global $blog, $sec_ID, $admin_url, $rsc_url; global $Session; -$perm_options_edit = $current_User->check_perm( 'options', 'edit', false ); +$perm_options_edit = check_user_perm( 'options', 'edit', false ); /** * View funcs diff --git a/inc/sessions/views/_stats_refdomains.view.php b/inc/sessions/views/_stats_refdomains.view.php index a9b2d6ace1c..84dddbd8f5a 100644 --- a/inc/sessions/views/_stats_refdomains.view.php +++ b/inc/sessions/views/_stats_refdomains.view.php @@ -19,7 +19,7 @@ require_once dirname(__FILE__).'/_stats_view.funcs.php'; -global $blog, $sec_ID, $admin_url, $rsc_url, $current_User, $UserSettings, $tab3; +global $blog, $sec_ID, $admin_url, $rsc_url, $UserSettings, $tab3; global $dname, $dtyp_normal, $dtyp_searcheng, $dtyp_aggregator, $dtyp_email, $dtyp_unknown; @@ -111,7 +111,7 @@ $Results = new Results( $SQL->get(), 'refdom_', '---D', $UserSettings->get( 'results_per_page' ), $count_SQL->get() ); -if( $current_User->check_perm( 'stats', 'edit' ) ) +if( check_user_perm( 'stats', 'edit' ) ) { // Current user has a permission to create new domain global $tab_from; $tab_from_param = empty( $tab_from ) ? '' : '&tab_from='.$tab_from; @@ -183,7 +183,7 @@ function filter_basedomains( & $Form ) 'th' => T_('Type'), 'order' => 'dom_type', 'td_class' => 'jeditable_cell dom_type_edit', - 'td' => /* Check permission: */$current_User->check_perm( 'stats', 'edit' ) ? + 'td' => /* Check permission: */check_user_perm( 'stats', 'edit' ) ? /* Current user can edit Domains */'%stats_dom_type_title( #dom_type# )%' : /* No edit */'%stats_dom_type_title( #dom_type# )%', ); @@ -199,7 +199,7 @@ function filter_basedomains( & $Form ) 'th' => T_('Status'), 'order' => 'dom_status', 'td_class' => 'jeditable_cell dom_status_edit', - 'td' => /* Check permission: */$current_User->check_perm( 'stats', 'edit' ) ? + 'td' => /* Check permission: */check_user_perm( 'stats', 'edit' ) ? /* Current user can edit Domains */'%stats_dom_status_title( #dom_status# )%' : /* No edit */'%stats_dom_status_title( #dom_status# )%', 'extra' => array( 'style' => 'background-color: %stats_dom_status_color( "#dom_status#" )%;', 'format_to_output' => false ) @@ -226,7 +226,7 @@ function filter_basedomains( & $Form ) ); } -if( $current_User->check_perm( 'stats', 'edit' ) ) +if( check_user_perm( 'stats', 'edit' ) ) { $Results->cols[] = array( 'th' => T_('Actions'), @@ -250,7 +250,7 @@ function dom_row_actions( $dom_ID ) // Display results: $Results->display(); -if( $current_User->check_perm( 'stats', 'edit' ) ) +if( check_user_perm( 'stats', 'edit' ) ) { // Check permission to edit Domains: // Print JS to edit a domain type echo_editable_column_js( array( diff --git a/inc/sessions/views/_stats_robots.view.php b/inc/sessions/views/_stats_robots.view.php index 8da6264c568..2002713d575 100644 --- a/inc/sessions/views/_stats_robots.view.php +++ b/inc/sessions/views/_stats_robots.view.php @@ -82,7 +82,7 @@ check_perm( 'stats', 'edit' ) ) + if( $is_live_mode && check_user_perm( 'stats', 'edit' ) ) { // Display a link to prune hits only for live data and if current user has a permission: echo action_icon( T_('Prune hits for this date!'), 'delete', $admin_url.'?ctrl=stats&action=prune&date='.$this_date.'&show=summary&blog='.$blog.'&'.url_crumb( 'stats' ) ); } diff --git a/inc/sessions/views/_stats_search_keywords.view.php b/inc/sessions/views/_stats_search_keywords.view.php index be23d8d963a..08013cde1a5 100644 --- a/inc/sessions/views/_stats_search_keywords.view.php +++ b/inc/sessions/views/_stats_search_keywords.view.php @@ -22,7 +22,7 @@ load_funcs('/cron/_cron.funcs.php'); global $blog, $sec_ID, $admin_url, $rsc_url, $goal_ID, $localtimenow; -global $datestartinput, $datestart, $datestopinput, $datestop; +global $datestartinput, $datestart, $datestopinput, $datestop, $keyword; if( param_date( 'datestartinput', T_('Invalid date'), false, NULL ) !== NULL ) { // We have a user provided localized date: @@ -43,7 +43,12 @@ param( 'datestop', 'string', '', true ); } -if( $current_User->check_perm( 'stats', 'view' ) ) +if( param( 'keyword', 'string', NULL ) !== NULL ) +{ // We have a user provided keyword: + memorize_param( 'keyword', 'string', NULL, get_param( 'keyword' ) ); +} + +if( check_user_perm( 'stats', 'view' ) ) { // Permission to view stats for ALL blogs: param( 'goal_ID', 'integer', 0, true ); $goal_name = param( 'goal_name', 'string', NULL, true ); @@ -118,6 +123,10 @@ } } $SQL->WHERE_and( 'hit_agent_type = "browser"' ); + if( ! empty( $keyword ) ) + { // Filter by keyword: + $SQL->WHERE_and( 'keyp_phrase LIKE '.$DB->quote( '%'.$keyword.'%' ) ); + } if( $split_engines ) { $SQL->GROUP_BY( 'keyp_ID, T_hitlog.hit_referer_dom_ID' ); @@ -181,12 +190,14 @@ */ function filter_keyphrases( & $Form ) { - global $current_User, $datestart, $datestop; + global $datestart, $datestop, $keyword; $Form->date_input( 'datestartinput', $datestart, T_('From') ); $Form->date_input( 'datestopinput', $datestop, T_('to') ); - if( $current_User->check_perm( 'stats', 'view' ) ) + $Form->text( 'keyword', $keyword, 50, T_('Contains keyword'), '', 255 ); + + if( check_user_perm( 'stats', 'view' ) ) { // Permission to view stats for ALL blogs: global $goal_ID; $GoalCache = & get_GoalCache(); @@ -206,7 +217,7 @@ function filter_keyphrases( & $Form ) $today = date( 'Y-m-d', $localtimenow ); $Results->filter_area = array( 'callback' => 'filter_keyphrases', - 'url_ignore' => 'goal_ID,datestartinput,datestart,datestopinput,datestop,goal_name,split_engines', + 'url_ignore' => 'goal_ID,datestartinput,datestart,datestopinput,datestop,keyword,goal_name,split_engines', ); $Results->register_filter_preset( 'all', T_('All'), '?ctrl=stats&tab=refsearches&tab3=keywords'.$section_params ); @@ -227,7 +238,7 @@ function filter_keyphrases( & $Form ) $Results->cols[] = array( 'th' => T_('Search keywords'), 'order' => 'keyp_phrase', - 'td' => '%stats_search_keywords( #keyp_phrase#, 45 )%', + 'td' => '$keyp_phrase$', 'total' => $sql_count.' '.T_('keyphrases'), ); diff --git a/inc/sessions/views/_stats_search_referers.view.php b/inc/sessions/views/_stats_search_referers.view.php index 9ab3909c542..7119487416a 100644 --- a/inc/sessions/views/_stats_search_referers.view.php +++ b/inc/sessions/views/_stats_search_referers.view.php @@ -103,7 +103,7 @@ check_perm( 'stats', 'edit' ) ) + if( $is_live_mode && check_user_perm( 'stats', 'edit' ) ) { // Display a link to prune hits only for live data and if current user has a permission: echo action_icon( T_('Prune hits for this date!'), 'delete', url_add_param( $admin_url, 'ctrl=stats&action=prune&date='.$last_date.'&show=summary'.$section_params.'&'.url_crumb('stats') ) ); } @@ -157,7 +157,7 @@ check_perm( 'stats', 'edit' ) ) + if( $is_live_mode && check_user_perm( 'stats', 'edit' ) ) { // Display a link to prune hits only for live data and if current user has a permission: echo action_icon( T_('Prune hits for this date!'), 'delete', url_add_param( $admin_url, 'ctrl=stats&action=prune&date='.$last_date.'&show=summary'.$section_params.'&'.url_crumb('stats') ) ); } diff --git a/inc/sessions/views/_stats_settings.form.php b/inc/sessions/views/_stats_settings.form.php index 7f66e3364ce..958a903efd6 100644 --- a/inc/sessions/views/_stats_settings.form.php +++ b/inc/sessions/views/_stats_settings.form.php @@ -13,10 +13,6 @@ */ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); -/** - * @var User - */ -global $current_User; /** * @var GeneralSettings */ @@ -77,7 +73,7 @@ $Form->end_fieldset(); -if( $current_User->check_perm( 'options', 'edit' ) ) +if( check_user_perm( 'options', 'edit' ) ) { $Form->end_form( array( array( 'submit', 'submit', TB_('Save Changes!'), 'SaveButton' ) ) ); } diff --git a/inc/sessions/views/_stats_summary.view.php b/inc/sessions/views/_stats_summary.view.php index fc3caf3760f..d4bb57c6b22 100644 --- a/inc/sessions/views/_stats_summary.view.php +++ b/inc/sessions/views/_stats_summary.view.php @@ -108,7 +108,7 @@ check_perm( 'stats', 'edit' ) ) + if( $is_live_mode && check_user_perm( 'stats', 'edit' ) ) { // Display a link to prune hits only for live data and if current user has a permission: echo action_icon( T_('Prune hits for this date!'), 'delete', url_add_param( $admin_url, 'ctrl=stats&action=prune&date='.$last_date.'&show=summary'.$section_params.'&'.url_crumb('stats') ) ); } @@ -180,7 +180,7 @@ check_perm( 'stats', 'edit' ) ) + if( $is_live_mode && check_user_perm( 'stats', 'edit' ) ) { // Display a link to prune hits only for live data and if current user has a permission: echo action_icon( T_('Prune hits for this date!'), 'delete', url_add_param( $admin_url, 'ctrl=stats&action=prune&date='.$last_date.'&show=summary'.$section_params.'&'.url_crumb('stats') ) ); } diff --git a/inc/sessions/views/_stats_syndication.view.php b/inc/sessions/views/_stats_syndication.view.php index c726256fb4f..ee474592320 100644 --- a/inc/sessions/views/_stats_syndication.view.php +++ b/inc/sessions/views/_stats_syndication.view.php @@ -79,7 +79,7 @@ check_perm( 'stats', 'edit' ) ) + if( $is_live_mode && check_user_perm( 'stats', 'edit' ) ) { // Display a link to prune hits only for live data and if current user has a permission: echo action_icon( T_('Prune hits for this date!'), 'delete', $admin_url.'?ctrl=stats&action=prune&date='.$this_date.'&show=summary&blog='.$blog.'&'.url_crumb( 'stats' ) ); } diff --git a/inc/sessions/views/_stats_view.funcs.php b/inc/sessions/views/_stats_view.funcs.php index ac22ed49bef..784161f24c2 100644 --- a/inc/sessions/views/_stats_view.funcs.php +++ b/inc/sessions/views/_stats_view.funcs.php @@ -363,12 +363,12 @@ function stat_session_hits( $sess_ID, $link_text ) */ function disp_clickable_log_IP( $hit_remote_addr ) { - global $current_User, $admin_url; + global $admin_url; static $perm = NULL; if( empty( $perm ) ) { - $perm = $current_User->check_perm( 'stats', 'view' ); + $perm = check_user_perm( 'stats', 'view' ); } if( $perm == true ) @@ -595,14 +595,14 @@ function hit_iprange_status( $IP_address ) */ function hit_iprange_status_title( $IP_address ) { - global $current_User, $admin_url; + global $admin_url; // Get status code of IP range by IP address $ip_range_status = hit_iprange_status( $IP_address ); if( $ip_range_status === '' ) { // No IP range for this IP address - if( $current_User->check_perm( 'spamblacklist', 'edit' ) ) + if( check_user_perm( 'spamblacklist', 'edit' ) ) { // Display a link to create new one if user has an access return ''.T_('Create').''; } @@ -612,7 +612,7 @@ function hit_iprange_status_title( $IP_address ) } } - if( $current_User->check_perm( 'spamblacklist', 'view' ) ) + if( check_user_perm( 'spamblacklist', 'view' ) ) { // Current user has access to view IP ranges global $blog; $blog_param = empty( $blog ) ? '' : '&blog=1'; @@ -1352,7 +1352,7 @@ function display_hits_diagram( $type, $diagram_columns, $res_hits, $canvas_id = $chart['series_color'] = array(); foreach( $diagram_columns as $diagram_column_key => $diagram_column_data ) { - $chart['series_color'][ $col_num ] = $diagram_column_data['color']; + $chart['series_color'][ $col_num - 1 ] = $diagram_column_data['color']; array_unshift( $chart['chart_data'][ $col_num++ ], $diagram_column_data['title'] ); } diff --git a/inc/settings/remotepublish.ctrl.php b/inc/settings/remotepublish.ctrl.php index 5cf58b6be07..45209f89396 100644 --- a/inc/settings/remotepublish.ctrl.php +++ b/inc/settings/remotepublish.ctrl.php @@ -14,8 +14,8 @@ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); // Check minimum permission: -$current_User->check_perm( 'admin', 'normal', true ); -$current_User->check_perm( 'options', 'view', true ); +check_user_perm( 'admin', 'normal', true ); +check_user_perm( 'options', 'view', true ); // Store/retrieve preferred tab from UserSettings: $UserSettings->param_Request( 'tab', 'pref_remotepublish_tab', 'string', 'eblog', true /* memorize */, true /* force */ ); @@ -35,7 +35,7 @@ $Session->assert_received_crumb( 'globalsettings' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); switch( $tab ) { @@ -128,7 +128,7 @@ $Session->assert_received_crumb( 'globalsettings' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); load_funcs( 'cron/model/_post_by_mail.funcs.php'); load_class( 'items/model/_itemlist.class.php', 'ItemList' ); diff --git a/inc/settings/views/_eblog.form.php b/inc/settings/views/_eblog.form.php index da38324d7d5..da7630bfe1e 100644 --- a/inc/settings/views/_eblog.form.php +++ b/inc/settings/views/_eblog.form.php @@ -14,10 +14,6 @@ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); -/** - * @var User - */ -global $current_User; /** * @var GeneralSettings */ @@ -151,7 +147,7 @@ $Form->end_fieldset(); -if( $current_User->check_perm( 'options', 'edit' ) ) +if( check_user_perm( 'options', 'edit' ) ) { $Form->end_form( array( array( 'submit', '', TB_('Save Changes!'), 'SaveButton' ) ) ); } diff --git a/inc/settings/views/_xmlrpc.form.php b/inc/settings/views/_xmlrpc.form.php index 1809a708fdc..41d98c5c5e0 100644 --- a/inc/settings/views/_xmlrpc.form.php +++ b/inc/settings/views/_xmlrpc.form.php @@ -14,10 +14,6 @@ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); -/** - * @var User - */ -global $current_User; /** * @var GeneralSettings */ @@ -42,7 +38,7 @@ $Form->text_input( 'xmlrpc_default_title', $Settings->get('xmlrpc_default_title'), 50, TB_('Default title'), '
    '.TB_('Default title for items created with a XML-RPC API that doesn\'t send a post title (e. g. the Blogger API).'), array( 'maxlength' => 255 ) ); $Form->end_fieldset(); -if( $current_User->check_perm( 'options', 'edit' ) ) +if( check_user_perm( 'options', 'edit' ) ) { $Form->end_form( array( array( 'submit', '', TB_('Save Changes!'), 'SaveButton' ) ) ); } diff --git a/inc/skins/_skin.funcs.php b/inc/skins/_skin.funcs.php index 7c1348dec79..9bdf7ffdb89 100644 --- a/inc/skins/_skin.funcs.php +++ b/inc/skins/_skin.funcs.php @@ -236,10 +236,10 @@ function skin_init( $disp ) { // If non-canonical URL is allowed for cross-posted items, then only get canonical URL in the main collection: $canonical_url = $main_canonical_url; } - // Keep ONLY allowed noredir params from current URL in the canonical URL: - $canonical_url = url_clear_noredir_params( $canonical_url, '&', array_keys( $Item->get_switchable_params() ) ); + // Keep ONLY allowed params from current URL in the canonical URL by configs AND Item's switchable params: + $canonical_url = url_keep_canonicals_params( $canonical_url, '&', array_keys( $Item->get_switchable_params() ) ); if( preg_match( '|[&?](revision=(p?\d+))|', $ReqURI, $revision_param ) - && ( is_logged_in() && $current_User->check_perm( 'item_post!CURSTATUS', 'edit', false, $Item ) ) + && check_user_perm( 'item_post!CURSTATUS', 'edit', false, $Item ) && $item_revision = $Item->get_revision( $revision_param[2] ) ) { // A revision of the post, keep only this param and discard all others: $canonical_url = url_add_param( $canonical_url, $revision_param[1], '&' ); @@ -259,8 +259,8 @@ function skin_init( $disp ) continue; } $cat_canonical_url = $Item->get_permanent_url( '', $Blog->get( 'url' ), '&', array(), $Blog->ID, $item_Chapter->ID ); - // Keep ONLY allowed noredir params from current URL in the category canonical URL: - $cat_canonical_url = url_clear_noredir_params( $cat_canonical_url ); + // Keep ONLY allowed params from current URL in the canonical URL by configs AND Item's switchable params: + $cat_canonical_url = url_keep_canonicals_params( $cat_canonical_url, '&', array_keys( $Item->get_switchable_params() ) ); if( $canonical_is_same_url = is_same_url( $ReqURL, $cat_canonical_url, $Blog->get_setting( 'http_protocol' ) == 'allow_both' ) ) { // We have found the same URL, stop find another and stay on the current page without redirect: break; @@ -336,6 +336,19 @@ function skin_init( $disp ) debug_die( 'Invalid page URL!' ); } + $seo_page_type = 'Download page'; + if( $Blog->get_setting( $disp.'_noindex' ) ) + { // We prefer robots not to index these pages: + $robots_index = false; + } + if( ! $Blog->get_setting( 'download_enable' ) ) + { // If download is disabled for current Collection: + global $disp; + $disp = '404'; + $disp_detail = '404-download-disabled'; + break; + } + $download_link_ID = param( 'download', 'integer', 0 ); // Check if we can allow to download the selected file @@ -362,37 +375,44 @@ function skin_init( $disp ) // Use meta tag to download file when JavaScript is NOT enabled add_headline( '' ); - - $seo_page_type = 'Download page'; - - if( $Blog->get_setting( $disp.'_noindex' ) ) - { // We prefer robots not to index these pages: - $robots_index = false; - } break; case 'posts': + if( ! $Blog->get_setting( 'postlist_enable' ) ) + { // If post list is disabled for current Collection: + global $disp; + $disp = '404'; + $disp_detail = '404-post-list-disabled'; + break; + } // fp> if we add this here, we have to exetnd the inner if() // init_ratings_js( 'blog' ); // Get list of active filters: $active_filters = $MainList->get_active_filters(); + $is_front_disp = ( $Blog->get_setting( 'front_disp' ) == 'posts' ); $is_first_page = ( empty( $active_filters ) || array_diff( $active_filters, array( 'posts' ) ) == array() ); $is_next_pages = ( ! $is_first_page && array_diff( $active_filters, array( 'posts', 'page' ) ) == array() ); - if( ( $is_first_page && $Blog->get_setting( 'front_disp' ) != 'posts' ) || $is_next_pages ) + if( ( $is_first_page && ! $is_front_disp ) || $is_next_pages ) { // This is first(but not front disp) or next pages of disp=posts: // Do we need to handle the canoncial url? if( ( $Blog->get_setting( 'canonical_posts' ) && $redir == 'yes' ) || $Blog->get_setting( 'relcanonical_posts' ) || $Blog->get_setting( 'self_canonical_posts' ) ) { // Check if the URL was canonical: - $canonical_url = url_add_param( $Blog->get( 'url' ), 'disp=posts', '&' ); + $canonical_url = $Blog->get( 'url', array( 'glue' => '&' ) ); + if( ! $is_front_disp ) + { // Append disp param only when this disp is not used as front page, because front page hides disp param in URL: + $canonical_url = url_add_param( $canonical_url, 'disp=posts', '&' ); + } if( $is_next_pages ) { // Set param for paged url: $canonical_url = url_add_param( $canonical_url, $MainList->page_param.'='.$MainList->filters['page'], '&' ); } + // Keep ONLY allowed params from current URL in the canonical URL by configs: + $canonical_url = url_keep_canonicals_params( $canonical_url ); if( ! is_same_url( $ReqURL, $canonical_url, $Blog->get_setting( 'http_protocol' ) == 'allow_both' ) ) { // We are not on the canonical blog url: if( $Blog->get_setting( 'canonical_posts' ) && $redir == 'yes' ) @@ -404,8 +424,10 @@ function skin_init( $disp ) add_headline( '' ); } } - elseif( $Blog->get_setting( 'self_canonical_posts' ) ) - { // Use self-referencing rel="canonical" tag: + elseif( $Blog->get_setting( 'self_canonical_posts' ) && + ! ( $is_front_disp && $Blog->get_setting( 'self_canonical_homepage' ) ) ) + { // Use self-referencing rel="canonical" tag, + // but don't add twice when it is already added for front page: add_headline( '' ); } } @@ -449,7 +471,9 @@ function skin_init( $disp ) global $cat, $catsel; - if( empty( $catsel ) && preg_match( '~^[0-9]+$~', $cat ) ) + if( ( empty( $catsel ) || // 'catsel' filter is not defined + ( is_array( $catsel ) && count( $catsel ) == 1 ) // 'catsel' filter is used for single cat, e.g. when skin config 'cat_array_mode' = 'parent' + ) && preg_match( '~^[0-9]+$~', $cat ) ) // 'cat' filter is ID of category and NOT modifier for 'catsel' multicats { // We are on a single cat page: // NOTE: we must have selected EXACTLY ONE CATEGORY through the cat parameter // BUT: - this can resolve to including children @@ -478,6 +502,8 @@ function skin_init( $disp ) } $canonical_url = $Chapter->get_permanent_url( NULL, NULL, $MainList->get_active_filter('page'), NULL, '&' ); + // Keep ONLY allowed params from current URL in the canonical URL by configs: + $canonical_url = url_keep_canonicals_params( $canonical_url ); if( ! is_same_url( $ReqURL, $canonical_url, $Blog->get_setting( 'http_protocol' ) == 'allow_both' ) ) { // fp> TODO: we're going to lose the additional params, it would be better to keep them... // fp> what additional params actually? @@ -531,6 +557,8 @@ function skin_init( $disp ) || $Blog->get_setting( 'self_canonical_tag_urls' ) ) { // Check if the URL was canonical: $canonical_url = $Blog->gen_tag_url( $MainList->get_active_filter('tags'), $MainList->get_active_filter('page'), '&' ); + // Keep ONLY allowed params from current URL in the canonical URL by configs: + $canonical_url = url_keep_canonicals_params( $canonical_url ); if( ! is_same_url($ReqURL, $canonical_url, $Blog->get_setting( 'http_protocol' ) == 'allow_both' ) ) { if( $Blog->get_setting( 'canonical_tag_urls' ) && $redir == 'yes' ) @@ -576,6 +604,8 @@ function skin_init( $disp ) || $Blog->get_setting( 'self_canonical_archive_urls' ) ) { // Check if the URL was canonical: $canonical_url = $Blog->gen_archive_url( substr( $m, 0, 4 ), substr( $m, 4, 2 ), substr( $m, 6, 2 ), $w, '&', $MainList->get_active_filter('page') ); + // Keep ONLY allowed params from current URL in the canonical URL by configs: + $canonical_url = url_keep_canonicals_params( $canonical_url ); if( ! is_same_url($ReqURL, $canonical_url, $Blog->get_setting( 'http_protocol' ) == 'allow_both' ) ) { if( $Blog->get_setting( 'canonical_archive_urls' ) && $redir == 'yes' ) @@ -624,6 +654,12 @@ function skin_init( $disp ) { // We prefer robots not to index these pages: $robots_index = false; } + if( ! $Blog->get_setting( 'search_enable' ) ) + { // If search is disabled for current Collection: + global $disp; + $disp = '404'; + $disp_detail = '404-search-disabled'; + } break; // SPECIAL FEATURE PAGES: @@ -836,9 +872,9 @@ function skin_init( $disp ) } // check if user status allow to view messages - if( !$current_User->check_status( 'can_view_messages' ) ) + if( ! check_user_status( 'can_view_messages' ) ) { // user status does not allow to view messages - if( $current_User->check_status( 'can_be_validated' ) ) + if( check_user_status( 'can_be_validated' ) ) { // user is logged in but his/her account is not activate yet $Messages->add( T_( 'You must activate your account before you can read & send messages. See below:' ) ); header_redirect( get_activate_info_url(), 302 ); @@ -851,7 +887,7 @@ function skin_init( $disp ) } // check if user permissions allow to view messages - if( !$current_User->check_perm( 'perm_messaging', 'reply' ) ) + if( ! check_user_perm( 'perm_messaging', 'reply' ) ) { // Redirect to the blog url for users without messaging permission $Messages->add( 'You are not allowed to view Messages!' ); header_redirect( $Blog->gen_blogurl(), 302 ); @@ -887,9 +923,9 @@ function skin_init( $disp ) // will have exited } - if( !$current_User->check_status( 'can_view_contacts' ) ) + if( ! check_user_status( 'can_view_contacts' ) ) { // user is logged in, but his status doesn't allow to view contacts - if( $current_User->check_status( 'can_be_validated' ) ) + if( check_user_status( 'can_be_validated' ) ) { // user is logged in but his/her account was not activated yet // Redirect to the account activation page $Messages->add( T_( 'You must activate your account before you can manage your contacts. See below:' ) ); @@ -914,7 +950,7 @@ function skin_init( $disp ) // Get action parameter from request: $action = param_action(); - if( ! $current_User->check_perm( 'perm_messaging', 'reply' ) ) + if( ! check_user_perm( 'perm_messaging', 'reply' ) ) { // Redirect to the blog url for users without messaging permission $Messages->add( 'You are not allowed to view Contacts!' ); $blogurl = $Blog->gen_blogurl(); @@ -945,7 +981,7 @@ function skin_init( $disp ) $Messages->add( 'User has been added to your contacts.', 'success' ); } } - header_redirect( $Blog->get( 'userurl', array( 'url_suffix' => 'user_ID='.$user_ID, 'glue' => '&' ) ) ); + header_redirect( $Blog->get( 'userurl', array( 'user_ID' => $user_ID ) ) ); } break; @@ -978,7 +1014,7 @@ function skin_init( $disp ) } else { // Redirect to the user profile page - header_redirect( $Blog->get( 'userurl', array( 'url_suffix' => 'user_ID='.$user_ID, 'glue' => '&' ) ) ); + header_redirect( $Blog->get( 'userurl', array( 'user_ID' => $user_ID ) ) ); } } } @@ -1061,9 +1097,9 @@ function skin_init( $disp ) // will have exited } - if( !$current_User->check_status( 'can_view_threads' ) ) + if( ! check_user_status( 'can_view_threads' ) ) { // user status does not allow to view threads - if( $current_User->check_status( 'can_be_validated' ) ) + if( check_user_status( 'can_be_validated' ) ) { // user is logged in but his/her account is not activate yet $Messages->add( T_( 'You must activate your account before you can read & send messages. See below:' ) ); header_redirect( get_activate_info_url(), 302 ); @@ -1079,7 +1115,7 @@ function skin_init( $disp ) // will have exited } - if( !$current_User->check_perm( 'perm_messaging', 'reply' ) ) + if( ! check_user_perm( 'perm_messaging', 'reply' ) ) { // Redirect to the blog url for users without messaging permission $Messages->add( 'You are not allowed to view Messages!' ); $blogurl = $Blog->gen_blogurl(); @@ -1114,7 +1150,7 @@ function skin_init( $disp ) { case 'new': // Check permission: - $current_User->check_perm( 'perm_messaging', 'reply', true ); + check_user_perm( 'perm_messaging', 'reply', true ); global $edited_Thread, $edited_Message; @@ -1155,7 +1191,7 @@ function skin_init( $disp ) default: // Check permission: - $current_User->check_perm( 'perm_messaging', 'reply', true ); + check_user_perm( 'perm_messaging', 'reply', true ); break; } break; @@ -1221,7 +1257,7 @@ function skin_init( $disp ) if( is_logged_in() ) { // User is already logged in - if( $current_User->check_status( 'can_be_validated' ) ) + if( check_user_status( 'can_be_validated' ) ) { // account is not active yet, redirect to the account activation page $Messages->add( T_( 'You are logged in but your account is not activated. You will find instructions about activating your account below:' ) ); header_redirect( get_activate_info_url(), 302 ); @@ -1332,7 +1368,7 @@ function skin_init( $disp ) // will have exited } - if( !$current_User->check_status( 'can_be_validated' ) ) + if( ! check_user_status( 'can_be_validated' ) ) { // don't display activateinfo screen $after_email_validation = $Settings->get( 'after_email_validation' ); if( $after_email_validation == 'return_to_original' ) @@ -1358,7 +1394,7 @@ function skin_init( $disp ) $redirect_to = ''; } - if( $current_User->check_status( 'is_validated' ) ) + if( check_user_status( 'is_validated' ) ) { $Messages->add( T_( 'Your account has already been activated.' ) ); } @@ -1449,6 +1485,22 @@ function skin_init( $disp ) // Check if current user has an access to view a profile of the requested user: check_access_user_profile( $user_ID ); + if( $Blog->get_setting( 'canonical_user_urls' ) && $redir == 'yes' ) + { // Check if current user profile URL can be canonical: + if( empty( $user_ID ) && is_logged_in() ) + { // Use ID of current User for proper redirect to canonical url like '/user:admin': + global $current_User; + $user_ID = $current_User->ID; + } + $canonical_url = $Blog->get( 'userurl', array( 'user_ID' => $user_ID, 'glue' => '&' ) ); + // Keep ONLY allowed params from current URL in the canonical URL by configs: + $canonical_url = url_keep_canonicals_params( $canonical_url ); + if( ! is_same_url( $ReqURL, $canonical_url, $Blog->get_setting( 'http_protocol' ) == 'allow_both' ) ) + { // Redirect to canonical user profile URL: + header_redirect( $canonical_url, true ); + } + } + // Initialize users list from session cache in order to display prev/next links: // It is used to navigate between users load_class( 'users/model/_userlist.class.php', 'UserList' ); @@ -1508,9 +1560,9 @@ function skin_init( $disp ) // will have exited } - if( !$current_User->check_status( 'can_edit_post' ) ) + if( ! check_user_status( 'can_edit_post' ) ) { - if( $current_User->check_status( 'can_be_validated' ) ) + if( check_user_status( 'can_be_validated' ) ) { // user is logged in but his/her account was not activated yet // Redirect to the account activation page $Messages->add( T_( 'You must activate your account before you can create & edit posts. See below:' ) ); @@ -1531,7 +1583,7 @@ function skin_init( $disp ) if( ! blog_has_cats( $Blog->ID ) ) { // No categories are in this blog $error_message = T_('Since this blog has no categories, you cannot post into it.'); - if( $current_User->check_perm( 'blog_cats', 'edit', false, $Blog->ID ) ) + if( check_user_perm( 'blog_cats', 'edit', false, $Blog->ID ) ) { // If current user has a permission to create a category $error_message .= ' '.sprintf( T_('You must create categories first.'), 'href="'.$admin_url.'?ctrl=chapters&blog='.$Blog->ID.'"'); } @@ -1567,9 +1619,9 @@ function skin_init( $disp ) // will have exited } - if( !$current_User->check_status( 'can_edit_comment' ) ) + if( ! check_user_status( 'can_edit_comment' ) ) { - if( $current_User->check_status( 'can_be_validated' ) ) + if( check_user_status( 'can_be_validated' ) ) { // user is logged in but his/her account was not activated yet // Redirect to the account activation page $Messages->add( T_( 'You must activate your account before you can edit comments. See below:' ) ); @@ -1594,7 +1646,7 @@ function skin_init( $disp ) $edited_Comment = $CommentCache->get_by_ID( $comment_ID ); $comment_Item = $edited_Comment->get_Item(); - if( ! $current_User->check_perm( 'comment!CURSTATUS', 'edit', false, $edited_Comment ) ) + if( ! check_user_perm( 'comment!CURSTATUS', 'edit', false, $edited_Comment ) ) { // If User has no permission to edit comments with this comment status: $Messages->add( 'You are not allowed to edit the previously selected comment!' ); header_redirect( $Blog->gen_blogurl(), 302 ); @@ -1615,9 +1667,6 @@ function skin_init( $disp ) // Restrict comment status by parent item: $edited_Comment->restrict_status(); - - // Init JS to quick upload several files: - init_fileuploader_js( 'blog' ); break; case 'useritems': @@ -1718,7 +1767,7 @@ function skin_init( $disp ) break; case 'closeaccount': - global $current_User, $disp; + global $disp; if( ! $Settings->get( 'account_close_enabled' ) ) { // If an account closing page is disabled - Display 404 page with error message: $disp = is_logged_in() ? 'profile' : 'login'; @@ -1729,7 +1778,7 @@ function skin_init( $disp ) $disp = 'login'; $Messages->add( T_('You must log in before you can close your account.'), 'error' ); } - elseif( is_logged_in() && $current_User->check_perm( 'users', 'edit', false ) ) + elseif( check_user_perm( 'users', 'edit', false ) ) { // Don't allow admins close own accounts from front office: $disp = 'profile'; $Messages->add( T_('You have user moderation privileges. In order to prevent mistakes, you cannot close your own account. Please ask the admin (or another admin) to remove your user moderation privileges before closing your account.'), 'error' ); @@ -3100,7 +3149,7 @@ function widget_page_containers( $item_ID, $params = array() ) */ function widget_container_customize_params( $params, $wico_code, $wico_name ) { - global $Collection, $Blog, $Session, $current_User; + global $Collection, $Blog, $Session; $params = array_merge( array( 'container_display_if_empty' => true, // FALSE - If no widget, don't display container at all, TRUE - Display container anyway @@ -3121,7 +3170,7 @@ function widget_container_customize_params( $params, $wico_code, $wico_name ) 'data-name' => $wico_name, 'data-code' => $wico_code, ); - if( $current_User->check_perm( 'blog_properties', 'edit', false, $Blog->ID ) ) + if( check_user_perm( 'blog_properties', 'edit', false, $Blog->ID ) ) { // Set data to know current user has a permission to edit this widget: $designer_mode_data['data-can-edit'] = 1; } @@ -3202,6 +3251,7 @@ function get_skin_default_containers() 'compare_main_area' => array( NT_('Compare Main Area'), 180 ), 'photo_index' => array( NT_('Photo Index'), 190 ), 'search_area' => array( NT_('Search Area'), 200 ), + 'sitemap' => array( NT_('Site Map'), 210 ), ); } @@ -3411,7 +3461,11 @@ function display_skin_fieldset( & $Form, $skin_ID, $display_params ) $tmp_params = array( 'for_editing' => true ); $skin_params = $edited_Skin->get_param_definitions( $tmp_params ); - if( empty( $skin_params ) ) + if( !skin_exists( $edited_Skin->folder ) ) + { + echo '

    '.T_('The skin files are missing.').'

    '; + } + elseif( empty( $skin_params ) ) { // Advertise this feature!! echo '

    '.T_('This skin does not provide any configurable settings.').'

    '; } @@ -3578,10 +3632,10 @@ function skin_body_attrs( $params = array() ) /** - * Get a skin's version + * Get skin version by ID * - * @param Integer skin's ID - * @return String skin's version + * @param integer Skin ID + * @return string Skin version */ function get_skin_version( $skin_ID ) { @@ -3699,4 +3753,51 @@ function get_skin_setting( $setting_name, $fallback_value = NULL ) return $setting_value; } + + +/** + * Output JavaScript code to confirm skin selection + */ +function echo_confirm_skin_selection_js() +{ + // Initialize JavaScript to build and open modal window: + echo_modalwindow_js(); ?> + + \ No newline at end of file diff --git a/inc/skins/model/_site_skin.class.php b/inc/skins/model/_site_skin.class.php index 94028d85290..18c9e56fb6f 100644 --- a/inc/skins/model/_site_skin.class.php +++ b/inc/skins/model/_site_skin.class.php @@ -29,7 +29,7 @@ class site_Skin extends Skin */ function get_site_header_param_definitions() { - global $current_User, $admin_url; + global $admin_url; // Set params for setting "Collection for Info Pages": $BlogCache = & get_BlogCache(); @@ -59,7 +59,7 @@ function get_site_header_param_definitions() ), 'menu_ID' => array( 'label' => T_('Menu to display'), - 'input_suffix' => ( is_logged_in() && $current_User->check_perm( 'options', 'edit' ) ? ' '.T_('Manage Menus').' >>' : '' ), + 'input_suffix' => ( check_user_perm( 'options', 'edit' ) ? ' '.T_('Manage Menus').' >>' : '' ), 'type' => 'select_object', 'object' => $SiteMenuCache, 'allow_none' => true, @@ -202,6 +202,7 @@ function get_header_tab_custom( $SiteMenuEntry ) 'name' => $SiteMenuEntry->get_text(), 'url' => $sub_tabs[0]['url'], 'items' => $sub_tabs, + 'class' => $SiteMenuEntry->get( 'class' ), ); } } @@ -211,6 +212,7 @@ function get_header_tab_custom( $SiteMenuEntry ) 'name' => $SiteMenuEntry->get_text(), 'url' => $menu_entry_url, 'active' => $SiteMenuEntry->is_active(), + 'class' => $SiteMenuEntry->get( 'class' ), ); } @@ -294,7 +296,7 @@ function get_header_tabs_auto() } if( $in_bloglist == 'member' && - ! $current_User->check_perm( 'blog_ismember', 'view', false, $group_Blog->ID ) ) + ! check_user_perm( 'blog_ismember', 'view', false, $group_Blog->ID ) ) { // Only members have an access to this collection, Skip it: continue; } @@ -383,6 +385,39 @@ function get_header_tabs_auto() } + /** + * Get attribute for header tab + * + * @param array Tab data + * @param integer Tab index in array of all tabs + * @param array Additional params + * @return string + */ + function get_header_tab_attr_class( $tab, $index = NULL, $params = array() ) + { + $params = array_merge( array( + 'class' => '', + 'class_active' => 'active', + ), $params ); + + $class = $params['class']; + + if( ! empty( $tab['class'] ) ) + { // Append extra CSS classes of Menu Entry: + $class .= ' '.$tab['class']; + } + + if( $this->header_tab_active === $index || ! empty( $tab['active'] ) ) + { // This tab is active currently: + $class .= ' '.$params['class_active']; + } + + $class = trim( $class ); + + return $class === '' ? '' : ' class="'.$class.'"'; + } + + /** * Get ID of collection for Info Pages * diff --git a/inc/skins/model/_skin.class.php b/inc/skins/model/_skin.class.php index ac022514da8..5e69595bc0b 100644 --- a/inc/skins/model/_skin.class.php +++ b/inc/skins/model/_skin.class.php @@ -300,6 +300,37 @@ function set( $parname, $parvalue, $make_null = false ) } + /** + * Get the declarations of the widgets that the skin recommends by default. + * + * The skin class defines a default set of widgets to used. Skins should override this. + * + * @param string Collection type: 'std', 'main', 'photo', 'group', 'forum', 'manual' + * @param string Skin type: 'normal' - Standard, 'mobile' - Phone, 'tablet' - Tablet + * @param array Additional params. Example value 'init_as_blog_b' => true + * @return array Array of default widgets: + * - Key - Container code, + * - Value - array of widget arrays OR SPECIAL VALUES: + * - 'coll_type': Include this container only for collection kinds separated by comma, first char "-" means to exclude, + * - 'type': Container type, empty - main container, other values: 'sub', 'page', 'shared', 'shared-sub', + * - 'name': Container name, + * - 'order': Container order, + * - widget data array(): + * - 0: Widget order (*mandatory field*), + * - 1: Widget code (*mandatory field*), + * - 'params' - Widget params(array or serialized string), + * - 'type' - Widget type(default = 'core', another value - 'plugin'), + * - 'enabled' - Boolean value; default is TRUE; FALSE to install the widget as disabled, + * - 'coll_type': Include this widget only for collection types separated by comma, first char "-" means to exclude, + * - 'skin_type': Include this widget only for skin types separated by comma, first char "-" means to exclude, + * - 'install' - Boolean value; default is TRUE; FALSE to skip this widget on install. + */ + function get_default_widgets( $coll_type, $skin_type = 'normal', $context = array() ) + { + return array( '*' => true ); // For all containers, use b2evo defaults. + } + + /** * Load data from Request form fields. * @@ -367,7 +398,7 @@ function container( $sco_name, $params = array(), $container_code = NULL ) */ global $Collection, $Blog; global $admin_url, $rsc_url; - global $Timer, $Session, $debug, $current_User; + global $Timer, $Session, $debug; $params = array_merge( array( 'container_display_if_empty' => true, // FALSE - If no widget, don't display container at all, TRUE - Display container anyway @@ -416,7 +447,7 @@ function container( $sco_name, $params = array(), $container_code = NULL ) if( $display_debug_containers ) { // Wrap container in visible container: echo '
    '; - if( is_logged_in() && $current_User->check_perm( 'blog_properties', 'edit', false, $Blog->ID ) ) + if( check_user_perm( 'blog_properties', 'edit', false, $Blog->ID ) ) { // Display a link to edit this widget only if current user has a permission: echo 'Edit'; } @@ -545,18 +576,18 @@ function discover_containers_by_folder( $folder, $exclude_files = array(), $disp break; } + // Store the file names to return + $files = array(); + if( ! $dir = @opendir( $skin_path ) ) { // Skin directory not found! if( $display_messages ) { $Messages->add( T_('Cannot open skin directory.'), 'error' ); // No trans } - return false; + return $files; } - // Store the file names to return - $files = array(); - // Go through all files in the skin directory: while( ( $file = readdir( $dir ) ) !== false ) { @@ -752,20 +783,24 @@ static function disp_skinshot( $skin_folder, $skin_name, $disp_params = array() 'highlighted' => false, ), $disp_params ); - if( isset( $disp_params[ 'select_url' ] ) ) - { - $skin_url = $disp_params[ 'select_url' ]; - $select_a_begin = ''; + if( isset( $disp_params['select_url'] ) ) + { // Initialize params for link to SELECT new skin for collection: + $skin_url = $disp_params['select_url']; + $select_a_begin = ''; $select_a_end = ''; } - elseif( isset( $disp_params[ 'function_url' ] ) ) - { - $skin_url = $disp_params[ 'function_url' ]; - $select_a_begin = ''; + elseif( isset( $disp_params['function_url'] ) ) + { // Initialize params for link to INSTALL new skin and probably select this automatically for collection: + $skin_url = $disp_params['function_url']; + $select_a_begin = ''; $select_a_end = ''; } else - { + { // No link: $skin_url = ''; $select_a_begin = ''; $select_a_end = ''; @@ -848,7 +883,7 @@ static function disp_skinshot( $skin_folder, $skin_name, $disp_params = array() echo ''; echo $link_text.''; } - if( empty( $kind ) && get_param( 'tab' ) != 'current_skin' ) + if( empty( $kind ) && get_param( 'tab' ) != 'coll_skin' && get_param( 'tab' ) != 'site_skin' ) { // Don't display the checkbox on new collection creating form and when we install one skin for the selected collection: $skin_name_before = ''; @@ -1287,7 +1322,7 @@ function dbupdate_settings() * This is where you'd specify you want to use BOOTSTRAP, etc. * * If this doesn't do what you need you may add functions like the following to your skin's display_init(): - * require_js() , require_css() , add_js_headline() + * require_js_async() , require_js_defer() , require_css() , add_js_headline() * * @param array of possible features you want to include. If empty, will default to {'b2evo_base', 'style', 'colorbox'} for backwards compatibility. */ @@ -1317,9 +1352,36 @@ function display_init( /*optional: $features = array() */ ) switch( $feature ) { + case 'superbundle': + // Include jQuery + Bootstrap + General front-office scripts: + require_js_defer( 'build/bootstrap-evo_frontoffice-superbundle.bmin.js', 'blog' ); + // Initialize font-awesome icons and use them as a priority over the glyphicons, @see get_icon() + init_fontawesome_icons( 'fontawesome-glyphicons', 'blog', false /* Don't load CSS file because it is bundled */ ); + // Include the bootstrap-b2evo_base CSS (NEW / v6 style) - Use this when you use Bootstrap: + if( $debug ) + { // Use readable CSS: + // rsc/css/font-awesome.css + // rsc/css/bootstrap/bootstrap.css + // rsc/build/bootstrap-b2evo_base.bundle.css: + // - rsc/less/bootstrap-basic_styles.less + // - rsc/less/bootstrap-basic.less + // - rsc/less/bootstrap-blog_base.less + // - rsc/less/bootstrap-item_base.less + // - rsc/less/bootstrap-evoskins.less + require_css( 'bootstrap-b2evo_base-superbundle.bundle.css', 'blog' ); // CSS concatenation of the above + } + else + { // Use minified CSS: + require_css( 'bootstrap-b2evo_base-superbundle.bmin.css', 'blog' ); // Concatenation + Minifaction of the above + } + break; + case 'jquery': // Include jQuery: - require_js( '#jquery#', 'blog' ); + if( ! in_array( 'superbundle', $features ) ) + { // Don't include when it is already bundled: + require_js_defer( '#jquery#', 'blog' ); + } break; case 'font_awesome': @@ -1329,8 +1391,11 @@ function display_init( /*optional: $features = array() */ ) case 'bootstrap': // Include Bootstrap: - require_js( '#bootstrap#', 'blog' ); - require_css( '#bootstrap_css#', 'blog' ); + if( ! in_array( 'superbundle', $features ) ) + { // Don't include when it is already bundled: + require_js_defer( '#bootstrap#', 'blog' ); + require_css( '#bootstrap_css#', 'blog' ); + } break; case 'bootstrap_theme_css': @@ -1339,6 +1404,10 @@ function display_init( /*optional: $features = array() */ ) break; case 'bootstrap_evo_css': + if( in_array( 'superbundle', $features ) ) + { // Don't include when it is already bundled: + break; + } // Include the bootstrap-b2evo_base CSS (NEW / v6 style) - Use this when you use Bootstrap: if( $debug ) { // Use readable CSS: @@ -1355,11 +1424,6 @@ function display_init( /*optional: $features = array() */ ) } break; - case 'bootstrap_init_tooltips': - // JS to init Bootstrap tooltips (E.g. on comment form for allowed file extensions): - add_js_headline( 'jQuery( function () { jQuery( \'[data-toggle="tooltip"]\' ).tooltip( {html: true} ) } )' ); - break; - case 'bootstrap_messages': // Initialize $Messages Class to use Bootstrap styles: $Messages->set_params( array( @@ -1437,7 +1501,7 @@ function display_init( /*optional: $features = array() */ ) case 'disp_page': // Specific features for disp=page: - global $Collection, $Blog, $Item, $current_User; + global $Collection, $Blog, $Item; if( ! empty( $Item ) && $Item->can_receive_webmentions() ) { // Send header and initialize tags in order to mark current Item can receive webmentions by current User(usually anonymous user): @@ -1463,27 +1527,24 @@ function display_init( /*optional: $features = array() */ ) if( $Blog->get_setting( 'allow_rating_comment_helpfulness' ) ) { // Load jquery UI to animate background color on change comment status or on vote: - require_js( '#jqueryUI#', 'blog' ); + require_js_defer( '#jqueryUI#', 'blog' ); } - if( is_logged_in() && $Blog->get_setting( 'use_workflow' ) && $current_User->check_perm( 'blog_can_be_assignee', 'edit', false, $Blog->ID ) ) + if( $Blog->get_setting( 'use_workflow' ) && check_user_perm( 'blog_can_be_assignee', 'edit', false, $Blog->ID ) ) { // Initialize JS to autcomplete user logins and date picker to edit workflow properties: init_autocomplete_login_js( 'blog', $this->get_template( 'autocomplete_plugin' ) ); init_datepicker_js( 'blog' ); } - // Used to quick upload several files: - init_fileuploader_js( 'blog' ); - // Used to change link position: - require_js( 'backoffice.js', 'blog' ); + require_js_defer( 'backoffice.js', 'blog' ); break; case 'disp_users': // Specific features for disp=users: // Used to add new search field "Specific criteria": - require_js( '#jqueryUI#', 'blog' ); + require_js_defer( '#jqueryUI#', 'blog' ); require_css( '#jqueryUI_css#', 'blog' ); // Load jQuery QueryBuilder plugin files for user list filters: init_querybuilder_js( 'blog' ); @@ -1495,7 +1556,7 @@ function display_init( /*optional: $features = array() */ ) } // Require functions.js to show/hide a panel with filters: - require_js( 'functions.js', 'blog' ); + require_js_defer( 'functions.js', 'blog' ); break; case 'disp_messages': @@ -1511,17 +1572,14 @@ function display_init( /*optional: $features = array() */ ) } // Require functions.js to show/hide a panel with filters: - require_js( 'functions.js', 'blog' ); - - // Init JS to quick upload several files: - init_fileuploader_js( 'blog' ); + require_js_defer( 'functions.js', 'blog' ); break; case 'disp_contacts': // Specific features for disp=contacts: // Used for combo box "Add all selected contacts to this group": - require_js( 'form_extensions.js', 'blog' ); + require_js_defer( 'form_extensions.js', 'blog' ); // Require results.css to display contact query results in a table if( ! in_array( 'bootstrap', $features ) ) @@ -1530,7 +1588,7 @@ function display_init( /*optional: $features = array() */ ) } // Require functions.js to show/hide a panel with filters: - require_js( 'functions.js', 'blog' ); + require_js_defer( 'functions.js', 'blog' ); break; case 'disp_threads': @@ -1549,6 +1607,9 @@ function display_init( /*optional: $features = array() */ ) { // Only for NON-bootstrap skins require_css( 'results.css', 'blog' ); // Results/tables styles } + + // Require functions.js to show/hide a panel with filters + require_js_defer( 'functions.js', 'blog' ); break; case 'disp_search': @@ -1566,8 +1627,10 @@ function display_init( /*optional: $features = array() */ ) global $Settings, $Plugins; if( can_use_hashed_password() ) - { // Include JS for client-side password hashing: - require_js( 'build/sha1_md5.bmin.js', 'blog' ); + { // Include JS for client-side password hashing: + require_js_defer( 'build/sha1_md5.bmin.js', 'blog' ); + require_js_defer( '#jquery#', 'blog' ); + require_js_defer( 'src/evo_init_display_login_js_handler.js', 'blog' ); } break; @@ -1578,14 +1641,14 @@ function display_init( /*optional: $features = array() */ ) init_userfields_js( 'blog', $this->get_template( 'tooltip_plugin' ) ); // Used to crop profile pictures: - require_js( '#jquery#', 'blog' ); - require_js( '#jcrop#', 'blog' ); + require_js_defer( '#jquery#', 'blog' ); + require_js_defer( '#jcrop#', 'blog' ); require_css( '#jcrop_css#', 'blog' ); // Activate bozo validator in order not to miss the changes of the edit forms on page leave: if( $UserSettings->get( 'control_form_abortions' ) ) { // Only if user wants this: - require_js( 'bozo_validator.js', 'blog' ); + require_js_defer( 'bozo_validator.js', 'blog' ); } break; @@ -1593,17 +1656,22 @@ function display_init( /*optional: $features = array() */ ) // Specific features for disp=avatar: // Used to crop profile pictures: - require_js( '#jquery#', 'blog' ); - require_js( '#jcrop#', 'blog' ); + require_js_defer( '#jquery#', 'blog' ); + require_js_defer( '#jcrop#', 'blog' ); require_css( '#jcrop_css#', 'blog' ); // Activate bozo validator in order not to miss the changes of the edit forms on page leave: if( $UserSettings->get( 'control_form_abortions' ) ) { // Only if user wants this: - require_js( 'bozo_validator.js', 'blog' ); + require_js_defer( 'bozo_validator.js', 'blog' ); } break; + case 'disp_visits': + // Require functions.js to show/hide a panel with filters + require_js_defer( 'functions.js', 'blog' ); + break; + case 'disp_pwdchange': // Specific features for disp=pwdchange: case 'disp_userprefs': @@ -1616,7 +1684,7 @@ function display_init( /*optional: $features = array() */ ) // Activate bozo validator in order not to miss the changes of the edit forms on page leave: if( $UserSettings->get( 'control_form_abortions' ) ) { // Only if user wants this: - require_js( 'bozo_validator.js', 'blog' ); + require_js_defer( 'bozo_validator.js', 'blog' ); } break; @@ -1638,10 +1706,10 @@ function display_init( /*optional: $features = array() */ ) init_popover_js( 'blog', $this->get_template( 'tooltip_plugin' ) ); // Used to switch to advanced editing and for link position changing: - require_js( 'backoffice.js', 'blog' ); + require_js_defer( 'backoffice.js', 'blog' ); // Used to automatically checks the matching extracat when we select a new main cat: - require_js( 'extracats.js', 'blog' ); + require_js_defer( 'extracats.js', 'blog' ); // Used to autocomplete usernames in textarea: init_autocomplete_usernames_js( 'blog' ); @@ -1649,11 +1717,8 @@ function display_init( /*optional: $features = array() */ ) // Activate bozo validator in order not to miss the changes of the edit forms on page leave: if( $UserSettings->get( 'control_form_abortions' ) ) { // Only if user wants this: - require_js( 'bozo_validator.js', 'blog' ); + require_js_defer( 'bozo_validator.js', 'blog' ); } - - // Used to quick upload several files: - init_fileuploader_js( 'blog' ); break; case 'disp_edit_comment': @@ -1678,10 +1743,7 @@ function display_init( /*optional: $features = array() */ ) init_autocomplete_usernames_js( 'blog' ); // Used to switch to advanced editing: - require_js( 'backoffice.js', 'blog' ); - - // Used to quick upload several files: - init_fileuploader_js( 'blog' ); + require_js_defer( 'backoffice.js', 'blog' ); break; case 'disp_useritems': @@ -1696,33 +1758,17 @@ function display_init( /*optional: $features = array() */ ) } // Require functions.js to show/hide a panel with filters - require_js( 'functions.js', 'blog' ); + require_js_defer( 'functions.js', 'blog' ); break; case 'disp_download': // Specific features for disp=download: global $Collection, $Blog; - require_js( '#jquery#', 'blog' ); + require_js_defer( '#jquery#', 'blog' ); // Initialize JavaScript to download file after X seconds - add_js_headline( ' -jQuery( document ).ready( function () -{ - jQuery( "#download_timer_js" ).show(); -} ); - -var b2evo_download_timer = '.intval( $Blog->get_setting( 'download_delay' ) ).'; -var downloadInterval = setInterval( function() -{ - jQuery( "#download_timer" ).html( b2evo_download_timer ); - if( b2evo_download_timer == 0 ) - { // Stop timer and download a file: - clearInterval( downloadInterval ); - jQuery( "#download_help_url" ).show(); - } - b2evo_download_timer--; -}, 1000 );' ); + expose_var_to_js( 'evo_disp_download_delay_config', intval( $Blog->get_setting( 'download_delay' ) ) ); break; default: @@ -1731,30 +1777,28 @@ function display_init( /*optional: $features = array() */ ) } } - // Check if current page has a marketing popup container: - $marketing_popup_container_code = $Blog->get_marketing_popup_container(); - - // Load general JS file: - if( $this->get_api_version() >= 6 ) - { // Bootstrap skin - require_js( $marketing_popup_container_code ? 'build/bootstrap-evo_frontoffice-with-ddexitpop.bmin.js' : 'build/bootstrap-evo_frontoffice.bmin.js', 'blog' ); - } - else - { // Standard skin - require_js( $marketing_popup_container_code ? 'build/evo_frontoffice-with-ddexitpop.bmin.js' : 'build/evo_frontoffice.bmin.js', 'blog' ); + if( ! in_array( 'superbundle', $features ) ) + { // Load general JS file only when it is not bundled above: + if( $this->get_api_version() >= 6 ) + { // Bootstrap skin + require_js_defer( 'build/bootstrap-evo_frontoffice.bmin.js', 'blog' ); + } + else + { // Standard skin + require_js_defer( 'build/evo_frontoffice.bmin.js', 'blog' ); + } } if( is_logged_in() && $Session->get( 'designer_mode_'.$Blog->ID ) ) { // If desinger mode when it is turned on from evo menu under "Designer Mode/Exit Designer" or "Collection" -> "Enable/Disable designer mode": - global $current_User; - require_js( '#jquery#', 'blog' ); - if( $current_User->check_perm( 'blog_properties', 'edit', false, $Blog->ID ) ) + require_js_defer( '#jquery#', 'blog' ); + if( check_user_perm( 'blog_properties', 'edit', false, $Blog->ID ) ) { // Initialize this url var only when current user has a permission to edit widgets: global $admin_url; - add_js_headline( 'var b2evo_widget_edit_url = "'.$admin_url.'?ctrl=widgets&action=edit&wi_ID=$wi_ID$&mode=customizer";' - .'var b2evo_widget_add_url = "'.$admin_url.'?ctrl=widgets&blog='.$Blog->ID.'&skin_type='.$Blog->get_skin_type().'&action=add_list&container=$container$&container_code=$container_code$&mode=customizer";' - .'var b2evo_widget_duplicate_url = "'.$admin_url.'?ctrl=widgets&action=duplicate&wi_ID=$wi_ID$&mode=customizer&crumb_widget=$crumb_widget$";' - .'var b2evo_widget_list_url = "'.$admin_url.'?ctrl=widgets&blog='.$Blog->ID.'&skin_type='.$Blog->get_skin_type().'&action=customize&container=$container$&container_code=$container_code$&mode=customizer";' + add_js_headline( 'var b2evo_widget_edit_url = "'.get_admin_url( 'ctrl=widgets&action=edit&wi_ID=$wi_ID$&mode=customizer', '&' ).'";' + .'var b2evo_widget_add_url = "'.get_admin_url( 'ctrl=widgets&blog='.$Blog->ID.'&skin_type='.$Blog->get_skin_type().'&action=add_list&container=$container$&container_code=$container_code$&mode=customizer', '&' ).'";' + .'var b2evo_widget_duplicate_url = "'.get_admin_url( 'ctrl=widgets&action=duplicate&wi_ID=$wi_ID$&mode=customizer&crumb_widget=$crumb_widget$', '&' ).'";' + .'var b2evo_widget_list_url = "'.get_admin_url( 'ctrl=widgets&blog='.$Blog->ID.'&skin_type='.$Blog->get_skin_type().'&action=customize&container=$container$&container_code=$container_code$&mode=customizer', '&' ).'";' .'var b2evo_widget_blog = \''.$Blog->ID.'\';' .'var b2evo_widget_crumb = \''.get_crumb( 'widget' ).'\';' .'var b2evo_widget_icon_top = \''.format_to_js( get_icon( 'designer_widget_top', 'imgtag', array( 'class' => 'evo_designer__action evo_designer__action_order_top' ) ) ).'\';' @@ -1772,8 +1816,8 @@ function display_init( /*optional: $features = array() */ ) .'var evo_js_lang_server_error = \''.TS_('There was a server side error.').'\';' .'var evo_js_lang_sync_error = \''.TS_('Please reload the page to be in sync with the server.').'\';' ); } - require_js( 'src/evo_widget_designer.js', 'blog' ); - require_js( 'communication.js', 'blog' ); + require_js_defer( 'src/evo_widget_designer.js', 'blog' ); + require_js_defer( 'communication.js', 'blog' ); } // Skin v7 specific initializations for kind of current collection: @@ -1792,7 +1836,7 @@ function display_init( /*optional: $features = array() */ ) * This is where you'd specify you want to use BOOTSTRAP, etc. * * If this doesn't do what you need you may add functions like the following to your skin's siteskin_init(): - * require_js() , require_css() , add_js_headline() + * require_js_async(), require_js_defer(), require_css(), add_js_headline() */ function siteskin_init() { @@ -2382,11 +2426,12 @@ function get_template( $name ) * this function is used to add unique version number for each skin * * @param string Name of CSS file relative to tag (current skin folder) + * @param string Position where the CSS file will be inserted, either 'headlines' (inside ) or 'footerlines' (before ) */ - function require_css( $css_file ) + function require_css( $css_file, $position = 'headlines' ) { global $app_version_long; - require_css( $css_file, 'relative', NULL, NULL, $this->folder.'+'.$this->version.'+'.$app_version_long ); + require_css( $this->get_url().$css_file, 'absolute', NULL, NULL, $this->folder.'+'.$this->version.'+'.$app_version_long, false, $position ); } @@ -2396,11 +2441,42 @@ function require_css( $css_file ) * this function is used to add unique version number for each skin * * @param string Name of JavaScript file relative to tag (current skin folder) + * @param boolean 'async' or TRUE to add attribute "async" to load javascript asynchronously, + * 'defer' to add attribute "defer" asynchronously in the order they occur in the page, + * 'immediate' or FALSE to load javascript immediately + * @param boolean TRUE to print script tag on the page, FALSE to store in array to print then inside + * @param string Position where the JS file will be inserted, either 'headlines' (inside ) or 'footerlines' (before ) */ - function require_js( $js_file ) + function require_js( $js_file, $async_defer = false, $output = false, $position = 'headlines' ) { global $app_version_long; - require_js( $js_file, 'relative', false, false, $this->folder.'+'.$this->version.'+'.$app_version_long ); + require_js( $this->get_url().$js_file, 'absolute', $async_defer, $output, $this->folder.'+'.$this->version.'+'.$app_version_long, $position ); + } + + + /** + * Require javascript file to load asynchronously with attribute "async" + * + * @param string Name of JavaScript file relative to tag (current skin folder) + * @param boolean TRUE to print script tag on the page, FALSE to store in array to print then inside + * @param string Position where the JS file will be inserted, either 'headlines' (inside ) or 'footerlines' (before ) + */ + function require_js_async( $js_file, $output = false, $position = 'headlines' ) + { + $this->require_js( $js_file, 'async', $output, $position ); + } + + + /** + * Require javascript file to load asynchronously with attribute "defer" in the order they occur in the page + * + * @param string Name of JavaScript file relative to tag (current skin folder) + * @param boolean TRUE to print script tag on the page, FALSE to store in array to print then inside + * @param string Position where the JS file will be inserted, either 'headlines' (inside ) or 'footerlines' (before ) + */ + function require_js_defer( $js_file, $output = false, $position = 'headlines' ) + { + $this->require_js( $js_file, 'defer', $output, $position ); } @@ -2554,4 +2630,4 @@ function call_func_by_coll_type( $func_name, $params ) } } -?> \ No newline at end of file +?> diff --git a/inc/skins/skins.ctrl.php b/inc/skins/skins.ctrl.php index 163685d8f6f..ca587b4c77e 100644 --- a/inc/skins/skins.ctrl.php +++ b/inc/skins/skins.ctrl.php @@ -27,12 +27,12 @@ if( $action != 'reset_coll' ) { // Check permission to display site options: // (exception for reset collection skin settings where we should check permission to edit collection properties) - $current_User->check_perm( 'options', 'view', true ); + check_user_perm( 'options', 'view', true ); } if( $tab == 'system' ) { // Check minimum permission: - $current_User->check_perm( 'admin', 'normal', true ); + check_user_perm( 'admin', 'normal', true ); } param( 'redirect_to', 'url', $admin_url.'?ctrl=skins&tab='.$tab.( isset( $blog ) ? '&blog='.$blog : '' ) ); @@ -74,7 +74,7 @@ $Session->assert_received_crumb( 'skin' ); // Check permission to edit: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // CREATE NEW SKIN: $edited_Skin = & skin_install( $skin_folder ); @@ -96,8 +96,11 @@ // Set new installed skins for the selected collection: $edited_Blog->set( $skin_type.'_skin_ID', $edited_Skin->ID ); $edited_Blog->dbupdate(); - // Re-scan and create widget containers from new switched skin if they don't exist for the edited collection: - $edited_Blog->db_save_main_containers(); + + if( param( 'reset_widgets', 'integer', 0 ) ) + { // Reset previous widgets with new from skin default widget declarations: + $edited_Blog->reset_widgets( $skin_type ); + } $Messages->add( TB_('The blog skin has been changed.') .' '.TB_('Edit...').'', 'success' ); @@ -173,7 +176,7 @@ $Session->assert_received_crumb( 'skin' ); // Check permission to edit: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); $SkinCache = & get_SkinCache(); @@ -208,7 +211,7 @@ $Session->assert_received_crumb( 'skin' ); // Check permission to edit: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); param( 'skin_folders', 'array:/([-A-Za-z0-9._]|\.\.)/', array() ); @@ -242,7 +245,7 @@ $Session->assert_received_crumb( 'skin' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure we got an skin_ID: param( 'skin_ID', 'integer', true ); @@ -271,7 +274,7 @@ $Session->assert_received_crumb( 'skin' ); // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure we got an skin_ID: param( 'skin_ID', 'integer', true ); @@ -314,7 +317,7 @@ { // Collection skin: // Check permission: - $current_User->check_perm( 'blog_properties', 'edit', true, $blog ); + check_user_perm( 'blog_properties', 'edit', true, $blog ); // At some point we may want to remove skin settings from all blogs $DB->query( 'DELETE FROM T_coll_settings @@ -327,7 +330,7 @@ { // Site skin: // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // At some point we may want to remove skin settings from all blogs $DB->query( 'DELETE FROM T_settings diff --git a/inc/skins/views/_coll_sel_skin.view.php b/inc/skins/views/_coll_sel_skin.view.php index 81d1742a8da..36958575756 100644 --- a/inc/skins/views/_coll_sel_skin.view.php +++ b/inc/skins/views/_coll_sel_skin.view.php @@ -51,7 +51,7 @@ $block_item_Widget->disp_template_replaced( 'block_start' ); echo '
    '; - if( $current_User->check_perm( 'options', 'edit', false ) ) + if( check_user_perm( 'options', 'edit', false ) ) { // A link to install new skin: echo ''.get_icon( 'new' ).T_('Install New').' »'.''; diff --git a/inc/skins/views/_coll_skin.view.php b/inc/skins/views/_coll_skin.view.php index 01e989cd78d..1400a8ffbfa 100644 --- a/inc/skins/views/_coll_skin.view.php +++ b/inc/skins/views/_coll_skin.view.php @@ -84,7 +84,7 @@ // Get what is the current skin ID from this kind of skin type $current_skin_ID = $is_collection_skin ? $edited_Blog->get( $skin_type.'_skin_ID', array( 'real_value' => true ) ) : $Settings->get( $skin_type.'_skin_ID', true ); -if( $current_User->check_perm( 'options', 'edit', false ) ) +if( check_user_perm( 'options', 'edit', false ) ) { // We have permission to modify: $block_item_Widget->global_icon( T_('Install new skin...'), 'new', $admin_url.'?ctrl=skins&tab='.( $is_collection_skin ? 'coll_skin&blog='.$edited_Blog->ID : 'site_skin' ).'&action=new&skin_type='.$skin_type.'&redirect_to='.rawurlencode(url_rel_to_same_host(regenerate_url('','skinpage=selection','','&'), $admin_url)), T_('Install new').' »', 3, 4, array( 'class' => 'action_icon btn-primary' ) ); $block_item_Widget->global_icon( T_('Keep current skin!'), 'close', regenerate_url( 'skinpage' ), ' '.T_('Don\'t change'), 3, 4 ); @@ -94,7 +94,7 @@ echo '
    '; - if( $current_User->check_perm( 'options', 'edit', false ) ) + if( check_user_perm( 'options', 'edit', false ) ) { // A link to install new skin: echo '' .get_icon( 'new' ) @@ -124,10 +124,9 @@ { foreach( $skins['yes'] as $iterator_Skin ) { - $selected = ( $current_skin_ID == $iterator_Skin->ID ); if( $is_collection_skin ) { // Collection skin: - $select_url = $admin_url.'?ctrl=coll_settings&tab=skin&blog='.$edited_Blog->ID.'&action=update&skinpage=selection&'.$skin_type.'_skin_ID='.$iterator_Skin->ID.'&'.url_crumb('collection'); + $select_url = $admin_url.'?ctrl=coll_settings&tab=skin&blog='.$edited_Blog->ID.'&action=update&skinpage=selection&'.$skin_type.'_skin_ID='.$iterator_Skin->ID.'&'.url_crumb( 'collection' ); $preview_url = url_add_param( $edited_Blog->gen_blogurl(), 'tempskin='.rawurlencode( $iterator_Skin->folder ) ); } else @@ -136,21 +135,18 @@ $preview_url = ''; } - $disp_params = array( - 'function' => 'select', - 'selected' => $selected, - 'select_url' => $select_url, - 'function_url' => $preview_url, - 'highlighted' => ( is_array( $fadeout_array ) && isset( $fadeout_array['skin_ID'] ) && in_array( $iterator_Skin->ID, $fadeout_array['skin_ID'] ) ), - ); // Display skinshot: - Skin::disp_skinshot( $iterator_Skin->folder, $iterator_Skin->name, $disp_params ); + Skin::disp_skinshot( $iterator_Skin->folder, $iterator_Skin->name, array( + 'function' => 'select', + 'selected' => ( $current_skin_ID == $iterator_Skin->ID ), + 'select_url' => $select_url, + 'onclick' => ( $is_collection_skin ? 'return confirm_skin_selection( this, "'.$iterator_Skin->type.'" )' : '' ), + 'function_url' => $preview_url, + 'highlighted' => ( is_array( $fadeout_array ) && isset( $fadeout_array['skin_ID'] ) && in_array( $iterator_Skin->ID, $fadeout_array['skin_ID'] ) ), + ) ); } } - // Flush fadeout - $Session->delete( 'fadeout_array'); - echo '
    '; echo '
    '; @@ -169,25 +165,17 @@ foreach( $skins['partial'] as $iterator_Skin ) { - $selected = ( $current_skin_ID == $iterator_Skin->ID ); - $blog_skin_param = $skin_type.'_skin_ID='; - $select_url = '?ctrl=coll_settings&tab=skin&blog='.$edited_Blog->ID.'&action=update&skinpage=selection&'.$blog_skin_param.$iterator_Skin->ID.'&'.url_crumb('collection'); - $preview_url = url_add_param( $edited_Blog->gen_blogurl(), 'tempskin='.rawurlencode($iterator_Skin->folder) ); - - $disp_params = array( - 'function' => 'select', - 'selected' => $selected, - 'select_url' => $select_url, - 'function_url' => $preview_url, - 'highlighted' => ( is_array( $fadeout_array ) && isset( $fadeout_array['skin_ID'] ) && in_array( $iterator_Skin->ID, $fadeout_array['skin_ID'] ) ), - ); // Display skinshot: - Skin::disp_skinshot( $iterator_Skin->folder, $iterator_Skin->name, $disp_params ); + Skin::disp_skinshot( $iterator_Skin->folder, $iterator_Skin->name, array( + 'function' => 'select', + 'selected' => ( $current_skin_ID == $iterator_Skin->ID ), + 'select_url' => $admin_url.'?ctrl=coll_settings&tab=skin&blog='.$edited_Blog->ID.'&action=update&skinpage=selection&'.$skin_type.'_skin_ID='.$iterator_Skin->ID.'&'.url_crumb( 'collection' ), + 'onclick' => ( $is_collection_skin ? 'return confirm_skin_selection( this, "'.$iterator_Skin->type.'" )' : '' ), + 'function_url' => url_add_param( $edited_Blog->gen_blogurl(), 'tempskin='.rawurlencode( $iterator_Skin->folder ) ), + 'highlighted' => ( is_array( $fadeout_array ) && isset( $fadeout_array['skin_ID'] ) && in_array( $iterator_Skin->ID, $fadeout_array['skin_ID'] ) ), + ) ); } - // Flush fadeout - $Session->delete( 'fadeout_array'); - echo '
    '; echo '
    '; $block_item_Widget->disp_template_replaced( 'block_end' ); @@ -205,27 +193,27 @@ foreach( $skins['maybe'] as $iterator_Skin ) { - $selected = ( $current_skin_ID == $iterator_Skin->ID ); - $blog_skin_param = $skin_type.'_skin_ID='; - $select_url = '?ctrl=coll_settings&tab=skin&blog='.$edited_Blog->ID.'&action=update&skinpage=selection&'.$blog_skin_param.$iterator_Skin->ID.'&'.url_crumb('collection'); - $preview_url = url_add_param( $edited_Blog->gen_blogurl(), 'tempskin='.rawurlencode($iterator_Skin->folder) ); - - $disp_params = array( - 'function' => 'select', - 'selected' => $selected, - 'select_url' => $select_url, - 'function_url' => $preview_url, - 'highlighted' => ( is_array( $fadeout_array ) && isset( $fadeout_array['skin_ID'] ) && in_array( $iterator_Skin->ID, $fadeout_array['skin_ID'] ) ), - ); // Display skinshot: - Skin::disp_skinshot( $iterator_Skin->folder, $iterator_Skin->name, $disp_params ); + Skin::disp_skinshot( $iterator_Skin->folder, $iterator_Skin->name, array( + 'function' => 'select', + 'selected' => ( $current_skin_ID == $iterator_Skin->ID ), + 'select_url' => $admin_url.'?ctrl=coll_settings&tab=skin&blog='.$edited_Blog->ID.'&action=update&skinpage=selection&'.$skin_type.'_skin_ID='.$iterator_Skin->ID.'&'.url_crumb( 'collection' ), + 'onclick' => ( $is_collection_skin ? 'return confirm_skin_selection( this, "'.$iterator_Skin->type.'" )' : '' ), + 'function_url' => url_add_param( $edited_Blog->gen_blogurl(), 'tempskin='.rawurlencode( $iterator_Skin->folder ) ), + 'highlighted' => ( is_array( $fadeout_array ) && isset( $fadeout_array['skin_ID'] ) && in_array( $iterator_Skin->ID, $fadeout_array['skin_ID'] ) ), + ) ); } - // Flush fadeout - $Session->delete( 'fadeout_array'); - echo '
    '; echo '
    '; $block_item_Widget->disp_template_replaced( 'block_end' ); } + +// Flush fadeout +$Session->delete( 'fadeout_array'); + +if( $is_collection_skin ) +{ // JavaScript code to confirm skin selection: + echo_confirm_skin_selection_js( $skin_type ); +} ?> \ No newline at end of file diff --git a/inc/skins/views/_coll_skin_settings.form.php b/inc/skins/views/_coll_skin_settings.form.php index d0584d9fd37..d16c4928de3 100644 --- a/inc/skins/views/_coll_skin_settings.form.php +++ b/inc/skins/views/_coll_skin_settings.form.php @@ -16,7 +16,7 @@ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); -global $Collection, $Blog, $Settings, $AdminUI, $current_User, $skin_type, $admin_url, $mode; +global $Collection, $Blog, $Settings, $AdminUI, $skin_type, $admin_url, $mode; switch( $skin_type ) { @@ -57,9 +57,9 @@ // When skin ID has a real value ( when $skin_ID = 0 means it must be the same as the normal skin value ) $skin_ID && // If current User can edit collection properties: - ( ( isset( $Blog ) && $current_User->check_perm( 'blog_properties', 'edit', false, $Blog->ID ) ) || + ( ( isset( $Blog ) && check_user_perm( 'blog_properties', 'edit', false, $Blog->ID ) ) || // If site skins are enabled and current User can edit site options: - ( $Settings->get( 'site_skins_enabled' ) && $current_User->check_perm( 'options', 'edit' ) ) + ( $Settings->get( 'site_skins_enabled' ) && check_user_perm( 'options', 'edit' ) ) ); if( $can_edit_skin_settings ) @@ -112,7 +112,7 @@ // Initialize a link to go to site/collection skin settings: if( isset( $Blog ) ) { // If collection skin page is opened currently: - if( $current_User->check_perm( 'options', 'view' ) ) + if( check_user_perm( 'options', 'view' ) ) { // If current user has a permission to view site skin: $goto_link_url = $admin_url.'?ctrl=collections&tab=site_skin'.( $skin_type == 'mobile' || $skin_type == 'tablet' || $skin_type == 'alt' ? '&skin_type='.$skin_type : '' ); $goto_link_title = TB_('Go to Site skin'); @@ -123,7 +123,7 @@ else { // If site skin page is opened currently: if( ( $working_coll_ID = get_working_blog() ) && - $current_User->check_perm( 'blog_properties', 'edit', false, $working_coll_ID ) ) + check_user_perm( 'blog_properties', 'edit', false, $working_coll_ID ) ) { // If working collection is set and current user has a permission to edit the collection skin: $goto_link_url = $admin_url.'?ctrl=coll_settings&tab=skin&blog='.$working_coll_ID.( $skin_type == 'mobile' || $skin_type == 'tablet' || $skin_type == 'alt' ? '&skin_type='.$skin_type : '' ); $goto_link_title = TB_('Go to Collection skin'); diff --git a/inc/skins/views/_skin_list.view.php b/inc/skins/views/_skin_list.view.php index 2d128120a8c..8260ee5605d 100644 --- a/inc/skins/views/_skin_list.view.php +++ b/inc/skins/views/_skin_list.view.php @@ -29,7 +29,7 @@ $Results->title = T_('Installed skins').get_manual_link('installed-skins'); -if( $current_User->check_perm( 'options', 'edit', false ) ) +if( check_user_perm( 'options', 'edit', false ) ) { // We have permission to modify: $Results->cols[] = array( 'th' => T_('Name'), @@ -100,7 +100,7 @@ function skin_col_provide_type( $Skin, $type ) 'td' => '$skin_folder$', ); -if( $current_User->check_perm( 'options', 'edit', false ) ) +if( check_user_perm( 'options', 'edit', false ) ) { // We have permission to modify: global $Settings; $site_skin_IDs = array( diff --git a/inc/skins/views/_skin_list_available.view.php b/inc/skins/views/_skin_list_available.view.php index 721ad143bdc..532bf8cdc36 100644 --- a/inc/skins/views/_skin_list_available.view.php +++ b/inc/skins/views/_skin_list_available.view.php @@ -72,7 +72,7 @@ $block_item_Widget->title = $block_title.get_manual_link( 'installing-skins' ); -if( $current_User->check_perm( 'options', 'edit', false ) ) +if( check_user_perm( 'options', 'edit', false ) ) { // We have permission to modify: $block_item_Widget->global_icon( T_('Cancel installation!'), 'close', $redirect_to ); } @@ -88,15 +88,19 @@ $Form->hidden( 'kind', get_param( 'kind' ) ); $Form->hidden( 'tab', $tab ); $Form->begin_form( 'skin_selector_filters' ); -$Form->select_input_array( 'sel_skin_type', $sel_skin_type, array( +$skin_type_options = array( '' => T_('All skins'), 'normal' => T_('Standard skins'), 'mobile' => T_('Phone skins'), 'tablet' => T_('Tablet skins'), 'alt' => T_('Alt skins'), - 'feed' => T_('Feed skins'), - 'sitemap' => T_('Sitemap skins'), - ), T_('Skin type'), '', array( + ); +if( get_param( 'tab' ) != 'coll_skin' && get_param( 'tab' ) != 'site_skin' ) +{ // Allow install feed and sitemap skins only on normal mode and don't allow when we select new skin for collection: + $skin_type_options['feed'] = T_('Feed skins'); + $skin_type_options['sitemap'] = T_('Sitemap skins'); +} +$Form->select_input_array( 'sel_skin_type', $sel_skin_type, $skin_type_options, T_('Skin type'), '', array( 'force_keys_as_values' => true, 'onchange' => 'this.form.submit()' ) ); @@ -338,7 +342,7 @@ if( $kind != '' && $folder_Skin->supports_coll_kind( $kind ) != 'yes' ) - { // Filter skin by support for collection type + { // Filter skin by support for collection type: $skin_folders_data[$skin_folder]['supported'] = false; $skin_folders_data[$skin_folder]['status'] = 'ignore'; } @@ -399,7 +403,8 @@ .( empty( $skin_type ) ? '' : '&skin_type='.$skin_type ) .'&skin_folder='.rawurlencode( $skin_folder ) .'&redirect_to='.rawurlencode( $redirect_to_after_install ) - .'&'.url_crumb( 'skin' ) + .'&'.url_crumb( 'skin' ), + 'onclick' => ( $tab == 'coll_skin' ? 'return confirm_skin_selection( this, "'.$folder_Skin->type.'" )' : '' ), ); $skin_folders_data[$skin_folder]['status'] = 'ok'; } @@ -480,6 +485,11 @@ $block_item_Widget->disp_template_replaced( 'block_end' ); +if( $tab == 'coll_skin' ) +{ // JavaScript code to confirm skin selection: + echo_confirm_skin_selection_js(); +} + ?> -check_perm( 'users', 'edit' ) ) + if( check_user_perm( 'users', 'edit' ) ) { // current user has global 'edit users' permission, these users have no restriction return false; } @@ -4692,14 +4654,14 @@ function has_cross_country_restriction( $type = 'users', $subtype = '' ) } break; } - return ! $current_User->check_perm( 'cross_country_allow_profiles' ); + return ! check_user_perm( 'cross_country_allow_profiles' ); case 'contact': // Check retsriction on contact - return ! $current_User->check_perm( 'cross_country_allow_contact' ); + return ! check_user_perm( 'cross_country_allow_contact' ); case 'any': // Check if there is any retsriction default: - return !( $current_User->check_perm( 'cross_country_allow_profiles' ) && $current_User->check_perm( 'cross_country_allow_contact' ) ); + return !( check_user_perm( 'cross_country_allow_profiles' ) && check_user_perm( 'cross_country_allow_contact' ) ); } } @@ -5797,7 +5759,7 @@ function user_report_form( $params = array() ) 'cancel_url' => '', ), $params ); - if( ! is_logged_in() || $current_User->ID == $params['user_ID'] || ! $current_User->check_status( 'can_report_user', $params['user_ID'] ) ) + if( ! is_logged_in() || $current_User->ID == $params['user_ID'] || ! check_user_status( 'can_report_user', $params['user_ID'] ) ) { // Current user must be logged in, cannot report own account, and must has a permission to report return; } @@ -5872,35 +5834,18 @@ function user_report_form( $params = array() ) */ function echo_user_organization_js() { - global $current_User; - - if( ! $current_User->check_perm( 'orgs', 'create' ) ) + if( ! check_user_perm( 'orgs', 'create' ) ) { // Check this min permission, because even owner of one organization can accept it: return; } -?> - - empty( $b2evo_icons_type ) ? '' : '&b2evo_icons_type='.$b2evo_icons_type, + 'crumb_userorg' => get_crumb( 'userorg' ), + ); + + expose_var_to_js( 'evo_user_organization_config', evo_json_encode( $user_organization_config ) ); } @@ -5911,9 +5856,9 @@ function echo_user_organization_js() */ function echo_user_add_organization_js( $edited_Organization ) { - global $admin_url, $current_User; + global $admin_url; - if( ! $current_User->check_perm( 'orgs', 'edit', false, $edited_Organization ) ) + if( ! check_user_perm( 'orgs', 'edit', false, $edited_Organization ) ) { // User must has an edit perm to add user to organization: return; } @@ -5938,9 +5883,9 @@ function echo_user_add_organization_js( $edited_Organization ) */ function echo_user_edit_membership_js( $edited_Organization ) { - global $admin_url, $current_User; + global $admin_url; - if( ! $current_User->check_perm( 'orgs', 'edit', false, $edited_Organization ) ) + if( ! check_user_perm( 'orgs', 'edit', false, $edited_Organization ) ) { // User must has an edit perm to edit user in organization: return; } @@ -5966,9 +5911,9 @@ function echo_user_edit_membership_js( $edited_Organization ) */ function echo_user_remove_membership_js( $edited_Organization ) { - global $admin_url, $current_User; + global $admin_url; - if( ! $current_User->check_perm( 'orgs', 'edit', false, $edited_Organization ) ) + if( ! check_user_perm( 'orgs', 'edit', false, $edited_Organization ) ) { // User must has an edit perm to remove user in organization: return; } @@ -6348,8 +6293,7 @@ function user_sent_emails_results_block( $params = array() ) return; } - global $current_User; - if( ! $current_User->check_perm( 'users', 'moderate' ) || ! $current_User->check_perm( 'emails', 'view' ) ) + if( ! check_user_perm( 'users', 'moderate' ) || ! check_user_perm( 'emails', 'view' ) ) { // Check minimum permission: return; } @@ -6385,7 +6329,7 @@ function user_sent_emails_results_block( $params = array() ) $emails_Results->title = $params['results_title']; $emails_Results->no_results_text = $params['results_no_text']; - if( $params['action'] != 'view' && $emails_Results->get_total_rows() > 0 && $current_User->check_perm( 'emails', 'edit' ) ) + if( $params['action'] != 'view' && $emails_Results->get_total_rows() > 0 && check_user_perm( 'emails', 'edit' ) ) { // Display action icon to delete all records if at least one record exists & user has a permission: $emails_Results->global_icon( sprintf( T_('Delete all emails sent to the User %s'), $edited_User->login ), 'delete', '?ctrl=user&user_tab=activity&action=delete_all_sent_emails&user_ID='.$edited_User->ID.'&'.url_crumb('user'), ' '.T_('Delete all'), 3, 4 ); } @@ -6438,8 +6382,7 @@ function user_email_returns_results_block( $params = array() ) return; } - global $current_User; - if( ! $current_User->check_perm( 'users', 'moderate' ) || ! $current_User->check_perm( 'emails', 'view' ) ) + if( ! check_user_perm( 'users', 'moderate' ) || ! check_user_perm( 'emails', 'view' ) ) { // Check minimum permission: return; } @@ -6474,7 +6417,7 @@ function user_email_returns_results_block( $params = array() ) $email_returns_Results->title = $params['results_title']; $email_returns_Results->no_results_text = $params['results_no_text']; - if( $params['action'] != 'view' && $email_returns_Results->get_total_rows() > 0 && $current_User->check_perm( 'emails', 'edit' ) ) + if( $params['action'] != 'view' && $email_returns_Results->get_total_rows() > 0 && check_user_perm( 'emails', 'edit' ) ) { // Display action icon to delete all records if at least one record exists & user has a permission: $email_returns_Results->global_icon( sprintf( T_('Delete all email returns from the User\'s email address %s'), $edited_User->get( 'email' ) ), 'delete', '?ctrl=user&user_tab=activity&action=delete_all_email_returns&user_ID='.$edited_User->ID.'&'.url_crumb( 'user' ), ' '.T_('Delete all'), 3, 4 ); } @@ -6526,8 +6469,7 @@ function user_reports_results_block( $params = array() ) return; } - global $current_User; - if( !$current_User->check_perm( 'users', 'moderate' ) ) + if( ! check_user_perm( 'users', 'moderate' ) ) { // Check minimum permission: return; } @@ -6715,7 +6657,7 @@ function merge_users( $merging_user_ID, $remaining_user_ID ) */ function user_reports_results( & $reports_Results, $params = array() ) { - global $admin_url, $current_User; + global $admin_url; $reports_Results->cols[] = array( 'th' => T_('Date and time'), @@ -6747,7 +6689,7 @@ function user_reports_results( & $reports_Results, $params = array() ) 'td' => '$urep_info$', ); - if( $current_User->check_perm( 'users', 'edit', false ) ) + if( check_user_perm( 'users', 'edit', false ) ) { // Allow actions if current user has a permission to edit the users $reports_Results->cols[] = array( 'th' => T_('Actions'), @@ -6857,17 +6799,10 @@ function users_results_block( $params = array() ) 'display_delspam_info' => false, ), $params ); - global $current_User; - if( ! $params['force_check_user'] ) - { - if( ! is_logged_in() ) - { // Only logged in users can access to this function - return; - } - if( ! $current_User->check_perm( 'users', 'view' ) ) - { // Check minimum permission: - return; - } + if( ! $params['force_check_user'] && + ! check_user_perm( 'users', 'view' ) ) + { // Check minimum permission to view users: + return; } global $DB, $UserSettings, $Settings, $Session, $action, $admin_url, $action; @@ -6949,13 +6884,13 @@ function users_results_block( $params = array() ) { // show "activated users" filter only on admin interface: $UserList->register_filter_preset( 'activated', T_('Activated users'), url_add_param( $params['page_url'], $new_filter_baseurl ) ); - if( is_logged_in() && $current_User->check_perm( 'users', 'edit' ) ) + if( check_user_perm( 'users', 'edit' ) ) { // Show "Reported Users" filter only to users with edit user permission: $UserList->register_filter_preset( 'reported', T_('Reported users'), url_add_param( $params['page_url'], $new_filter_baseurl ) ); } } - if( is_admin_page() && is_logged_in() && $current_User->check_perm( 'users', 'edit' ) ) + if( is_admin_page() && check_user_perm( 'users', 'edit' ) ) { // Settings for default user list filters: $UserList->filter_area['advanced_defaults_jsfunc'] = 'evo_users_list_default_filters()'; // Initialize JavaScript for AJAX loading of popup window to change default filters on users list: @@ -6973,7 +6908,7 @@ function users_results_block( $params = array() ) $UserList->global_icon( T_('Import Users'), 'new', $admin_url.'?ctrl=users&action=csv', T_('Import Users').' »', 3, 4 ); - if( is_logged_in() && $current_User->check_perm( 'users', 'edit', false ) ) + if( check_user_perm( 'users', 'edit', false ) ) { if( $params['display_btn_adduser'] ) { // Display a button to add user @@ -6989,7 +6924,7 @@ function users_results_block( $params = array() ) { // Display a button to add user to the organization: $OrganizationCache = & get_OrganizationCache(); if( $Organization = & $OrganizationCache->get_by_ID( $params['org_ID'], false, false ) && - $current_User->check_perm( 'orgs', 'edit', false, $Organization ) ) + check_user_perm( 'orgs', 'edit', false, $Organization ) ) { // If current user has a perm to edit the organization: $UserList->global_icon( T_('Add user'), 'new', '#', T_('Add user'), 3, 4, array( 'class' => 'action_icon btn-primary', @@ -7016,7 +6951,7 @@ function users_results_block( $params = array() ) $user_list_buttons = array(); - if( $params['display_btn_tags'] && is_logged_in() && $current_User->check_perm( 'users', 'edit' ) && $UserList->result_num_rows > 0 ) + if( $params['display_btn_tags'] && check_user_perm( 'users', 'edit' ) && $UserList->result_num_rows > 0 ) { // Button to add/remove tags from/to users: $user_list_buttons[] = '' .format_to_output( T_('Add/Remove tags...') ) @@ -7025,7 +6960,7 @@ function users_results_block( $params = array() ) echo_userlist_tags_js(); } - if( $params['display_btn_account_status'] && is_logged_in() && $current_User->check_perm( 'users', 'edit' ) && $UserList->result_num_rows > 0 ) + if( $params['display_btn_account_status'] && check_user_perm( 'users', 'edit' ) && $UserList->result_num_rows > 0 ) { // Button to set user account status: $user_list_buttons[] = '' .format_to_output( T_('Set account status...') ) @@ -7034,7 +6969,7 @@ function users_results_block( $params = array() ) echo_userlist_set_account_status_js(); } - if( $params['display_btn_change_groups'] && is_logged_in() && $current_User->check_perm( 'users', 'edit' ) && $UserList->result_num_rows > 0 ) + if( $params['display_btn_change_groups'] && check_user_perm( 'users', 'edit' ) && $UserList->result_num_rows > 0 ) { // Button to change user groups: $user_list_buttons[] = '' .format_to_output( T_('Change groups...') ) @@ -7043,7 +6978,7 @@ function users_results_block( $params = array() ) echo_userlist_change_groups_js(); } - if( $params['display_automation'] && is_logged_in() && $current_User->check_perm( 'options', 'edit' ) && $UserList->result_num_rows > 0 ) + if( $params['display_automation'] && check_user_perm( 'options', 'edit' ) && $UserList->result_num_rows > 0 ) { // Button to add users to an automation: $user_list_buttons[] = '' .format_to_output( T_('Add users to Automation...') ) @@ -7052,7 +6987,7 @@ function users_results_block( $params = array() ) echo_userlist_automation_js(); } - if( $params['display_newsletter'] && is_logged_in() && $current_User->check_perm( 'emails', 'edit' ) && $UserList->result_num_rows > 0 ) + if( $params['display_newsletter'] && check_user_perm( 'emails', 'edit' ) && $UserList->result_num_rows > 0 ) { // Button to change users of email campaign OR Create new email campaign for current selection: load_funcs( 'email_campaigns/model/_emailcampaign.funcs.php' ); if( $edited_EmailCampaign = & get_session_EmailCampaign() ) @@ -7090,7 +7025,7 @@ function users_results_block( $params = array() ) .''; } - if( is_logged_in() && $current_User->check_perm( 'users', 'edit' ) && $UserList->result_num_rows > 0 ) + if( check_user_perm( 'users', 'edit' ) && $UserList->result_num_rows > 0 ) { // Buttons and info to delete spammers: if( $params['display_btn_delspam'] ) { // Button to go to list with confirmation before spammers deleting: @@ -7134,7 +7069,7 @@ function users_results_block( $params = array() ) */ function users_results( & $UserList, $params = array() ) { - global $Settings, $current_User, $collections_Module, $admin_url; + global $Settings, $collections_Module, $admin_url; // Make sure we are not missing any param: $params = array_merge( array( @@ -7226,7 +7161,7 @@ function users_results( & $UserList, $params = array() ) * Group columns: */ $UserList->grp_cols[] = array( - 'td_class' => 'firstcol'.($current_User->check_perm( 'users', 'edit', false ) ? '' : ' lastcol' ), + 'td_class' => 'firstcol'.(check_user_perm( 'users', 'edit', false ) ? '' : ' lastcol' ), 'td_colspan' => -1, // nb_colds - 1 'td' => '$grp_name$' .'~conditional( (#grp_ID# == '.$Settings->get('newusers_grp_ID').'), \' ('.T_('default group for new users').')\' )~', @@ -7314,7 +7249,7 @@ function users_results( & $UserList, $params = array() ) if( $params['display_nickname'] ) { // Display nickname $nickname_editing = $Settings->get( 'nickname_editing' ); - if( $nickname_editing != 'hidden' && $current_User->check_perm( 'users', 'edit' ) ) + if( $nickname_editing != 'hidden' && check_user_perm( 'users', 'edit' ) ) { $UserList->cols[] = array( 'th' => T_('Nickname'), @@ -7464,7 +7399,7 @@ function users_results( & $UserList, $params = array() ) ); } - if( $params['display_source'] && $current_User->check_perm( 'users', 'edit', false ) ) + if( $params['display_source'] && check_user_perm( 'users', 'edit', false ) ) { // Display source $UserList->cols[] = array( 'th' => T_('Source'), @@ -7815,7 +7750,7 @@ function users_results( & $UserList, $params = array() ) ); } - if( is_logged_in() && ! $current_User->check_perm( 'users', 'moderate' ) ) + if( is_logged_in() && ! check_user_perm( 'users', 'moderate' ) ) { // Current user has no permissions to moderate the users if( isset( $userlist_col_reputaion ) ) { // Display the reported users @@ -7976,10 +7911,10 @@ function user_td_email( $email, $link_type = NULL, $user_row = NULL ) function user_td_grp_actions( & $row ) { - global $usedgroups, $Settings, $current_User; + global $usedgroups, $Settings; $r = ''; - if( $current_User->check_perm( 'users', 'edit', false ) ) + if( check_user_perm( 'users', 'edit', false ) ) { $r = action_icon( T_('Edit this group...'), 'edit', regenerate_url( 'ctrl,action', 'ctrl=groups&action=edit&grp_ID='.$row->grp_ID ) ); @@ -8103,12 +8038,10 @@ function user_td_pm( $user_ID, $user_login ) function user_td_status( $user_status, $user_ID ) { - global $current_User; - $user_status_icons = get_user_status_icons( true ); $status_content = $user_status_icons[ $user_status ]; - if( is_admin_page() && ( $current_User->check_perm( 'users', 'edit' ) ) ) + if( is_admin_page() && ( check_user_perm( 'users', 'edit' ) ) ) { // current User is an administrator and view is displayed on admin interface, return link to user admin tab return ''.$status_content.''; } @@ -8126,7 +8059,7 @@ function user_td_status( $user_status, $user_ID ) */ function user_td_subscribed_list( $lists, $user_email = '' ) { - global $current_User, $admin_url; + global $admin_url; if( empty( $lists ) ) { @@ -8148,7 +8081,7 @@ function user_td_subscribed_list( $lists, $user_email = '' ) if( $loop_List = $NewsletterCache->get_by_ID( $list_ID, false ) ) { - if( $current_User->check_perm( 'emails', 'view' ) ) + if( check_user_perm( 'emails', 'view' ) ) { // Display a newsletter as link if current use has a permission to view newsletters list: $user_email_filter = ( empty( $user_email ) ? '' : '&filter=new&keywords='.rawurlencode( $user_email ) ); $lists_array[] = 'get_by_ID( $tag_ID, false ) ) { - if( $current_User->check_perm( 'options', 'edit' ) ) + if( check_user_perm( 'options', 'edit' ) ) { $tag_links[] = ''.$loop_Tag->dget( 'name' ).''; } @@ -8234,7 +8167,7 @@ function user_td_user_tags( $tags ) */ function user_td_reg_country( $user_ID, $country_code, $country_name ) { - global $current_User, $admin_url; + global $admin_url; $flag = country_flag( $country_code, $country_name, 'w16px', 'flag', '', false, true, '', false ); if( empty( $flag ) ) @@ -8242,7 +8175,7 @@ function user_td_reg_country( $user_ID, $country_code, $country_name ) $flag = '?'; } - if( $current_User->check_perm( 'users', 'edit' ) ) + if( check_user_perm( 'users', 'edit' ) ) { // Only users with edit all users permission can see the 'Sessions' tab $flag = ''.$flag.''; } @@ -8341,7 +8274,7 @@ function user_td_actions( $user_ID ) { $r .= get_icon( 'edit', 'noimg' ); } - if( $current_User->check_perm( 'users', 'edit', false ) ) + if( check_user_perm( 'users', 'edit', false ) ) { // Current user can edit all users $r .= action_icon( T_('Duplicate this user...'), 'copy', regenerate_url( 'ctrl,action', 'ctrl=user&action=new&user_ID='.$user_ID.'&user_tab=profile' ) ); if( $user_ID != 1 && $user_ID != $current_User->ID ) @@ -8367,12 +8300,10 @@ function user_td_actions( $user_ID ) */ function user_td_org_actions( $org_ID, $user_ID ) { - global $current_User; - $r = ''; $OrganizationCache = & get_OrganizationCache(); if( ( $user_Organization = & $OrganizationCache->get_by_ID( $org_ID, false, false ) ) && - $current_User->check_perm( 'orgs', 'edit', false, $user_Organization ) ) + check_user_perm( 'orgs', 'edit', false, $user_Organization ) ) { // Current user can edit membership information: $link_params = array( 'onclick' => 'return user_edit( '.$org_ID.', '.$user_ID.' );' @@ -8450,12 +8381,10 @@ function user_td_campaign_actions( $campaign_ID, $user_ID, $csnd_status ) */ function user_td_orgstatus( $user_ID, $org_ID, $is_accepted ) { - global $current_User; - $OrganizationCache = & get_OrganizationCache(); $Organization = & $OrganizationCache->get_by_ID( $org_ID ); - if( $current_User->check_perm( 'orgs', 'edit', false, $Organization ) ) + if( check_user_perm( 'orgs', 'edit', false, $Organization ) ) { // Set the spec params for icon if user can edit the organization: $accept_icon_params = array( 'style' => 'cursor: pointer;', 'rel' => 'org_status_'.( $is_accepted ? 'y' : 'n' ).'_'.$org_ID.'_'.$user_ID ); } @@ -8483,7 +8412,7 @@ function user_td_orgstatus( $user_ID, $org_ID, $is_accepted ) */ function user_td_email_status( $emadr_status, $emadr_ID ) { - global $current_User, $admin_url; + global $admin_url; if( empty( $emadr_status ) ) { // If email address does not exist in DB: @@ -8492,7 +8421,7 @@ function user_td_email_status( $emadr_status, $emadr_ID ) $status_content = emadr_get_status_icon( $emadr_status ).' '.emadr_get_status_title( $emadr_status ); - if( is_admin_page() && $emadr_ID > 0 && $current_User->check_perm( 'emails', 'view' ) ) + if( is_admin_page() && $emadr_ID > 0 && check_user_perm( 'emails', 'view' ) ) { // Return a link to view email address details if current User has a permission: return ''.$status_content.''; } @@ -8529,9 +8458,8 @@ function user_td_campaign_status( $csnd_status, $csnd_emlog_ID = NULL, $email_st case 'send_error': case 'cannot_send': // This status doesn't exist in DB! - global $current_User; $status_text = ( $csnd_status == 'cannot_send' ? T_('Cannot send') : T_('Send error') ); - if( ! empty( $csnd_emlog_ID ) && $current_User->check_perm( 'emails', 'view' ) ) + if( ! empty( $csnd_emlog_ID ) && check_user_perm( 'emails', 'view' ) ) { // Make a link to view details of error sending: $status_text = ''.$status_text.''; } @@ -8645,7 +8573,7 @@ function validate_pwd_reset_session( $reqID, $forgetful_User ) */ function user_domain_info_display( $field_title, $field_key, $domain_name, & $Form ) { - global $current_User, $admin_url, $UserSettings; + global $admin_url, $UserSettings; if( ! is_logged_in() ) { // Only for logged in users: @@ -8653,8 +8581,8 @@ function user_domain_info_display( $field_title, $field_key, $domain_name, & $Fo } $domain_name_formatted = format_to_output( $domain_name ); - $display_user_domain = ( ! empty( $domain_name ) && $current_User->check_perm( 'stats', 'list' ) ); - $perm_stat_edit = $current_User->check_perm( 'stats', 'edit' ); + $display_user_domain = ( ! empty( $domain_name ) && check_user_perm( 'stats', 'list' ) ); + $perm_stat_edit = check_user_perm( 'stats', 'edit' ); if( $display_user_domain ) { // Get Domain: $DomainCache = & get_DomainCache(); @@ -8857,7 +8785,7 @@ function display_user_groups_selectors( & $User, & $Form ) $GroupCache = & get_GroupCache(); $group_where_sql = ''; - if( ! $current_User->check_perm( 'users', 'edit' ) ) + if( ! check_user_perm( 'users', 'edit' ) ) { // Show the limited list for moderators: $group_where_sql = 'grp_level < '.$current_User->get_Group()->get( 'level' ); } @@ -8933,4 +8861,4 @@ function display_user_groups_selectors( & $User, & $Form ) \ No newline at end of file +?> diff --git a/inc/users/model/_user_js.funcs.php b/inc/users/model/_user_js.funcs.php index 89435600c28..15add744fb0 100644 --- a/inc/users/model/_user_js.funcs.php +++ b/inc/users/model/_user_js.funcs.php @@ -2,62 +2,20 @@ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); -?> - - \ No newline at end of file +?> diff --git a/inc/users/organizations.ctrl.php b/inc/users/organizations.ctrl.php index a1c6d0701dd..b1ebac2df16 100644 --- a/inc/users/organizations.ctrl.php +++ b/inc/users/organizations.ctrl.php @@ -21,7 +21,7 @@ global $current_User; // Check minimum permission: -$current_User->check_perm( 'orgs', 'create', true ); +check_user_perm( 'orgs', 'create', true ); // Set options path: $AdminUI->set_path( 'users', 'organizations' ); @@ -48,7 +48,7 @@ { case 'new': // Check permission: - $current_User->check_perm( 'orgs', 'create', true ); + check_user_perm( 'orgs', 'create', true ); if( ! isset( $edited_Organization ) ) { // We don't have a model to use, start with blank object: @@ -64,7 +64,7 @@ case 'edit': // Check permission: - $current_User->check_perm( 'orgs', 'view', true, $edited_Organization ); + check_user_perm( 'orgs', 'view', true, $edited_Organization ); // Make sure we got an org_ID: param( 'org_ID', 'integer', true ); @@ -80,7 +80,7 @@ $Session->assert_received_crumb( 'organization' ); // Check permission: - $current_User->check_perm( 'orgs', 'create', true ); + check_user_perm( 'orgs', 'create', true ); // load data from request if( $edited_Organization->load_from_Request() ) @@ -139,7 +139,7 @@ $Session->assert_received_crumb( 'organization' ); // Check permission: - $current_User->check_perm( 'orgs', 'edit', true, $edited_Organization ); + check_user_perm( 'orgs', 'edit', true, $edited_Organization ); // Make sure we got an org_ID: param( 'org_ID', 'integer', true ); @@ -180,7 +180,7 @@ $Session->assert_received_crumb( 'organization' ); // Check permission: - $current_User->check_perm( 'orgs', 'edit', true, $edited_Organization ); + check_user_perm( 'orgs', 'edit', true, $edited_Organization ); // Make sure we got an org_ID: param( 'org_ID', 'integer', true ); @@ -213,7 +213,7 @@ $Session->assert_received_crumb( 'organization' ); // Check permission: - $current_User->check_perm( 'orgs', 'edit', true, $edited_Organization ); + check_user_perm( 'orgs', 'edit', true, $edited_Organization ); $user_login = param( 'user_login', 'string', NULL ); param_check_not_empty( 'user_login', TB_('Please enter the login of the user you wish to add.') ); @@ -261,7 +261,7 @@ $Session->assert_received_crumb( 'organization' ); // Check permission: - $current_User->check_perm( 'orgs', 'edit', true, $edited_Organization ); + check_user_perm( 'orgs', 'edit', true, $edited_Organization ); $user_login = param( 'user_login', 'string', NULL ); param_check_not_empty( 'user_login', TB_('Please enter the login of the user you wish to add.') ); diff --git a/inc/users/registration.ctrl.php b/inc/users/registration.ctrl.php index 437afca1540..4be524d5f7a 100644 --- a/inc/users/registration.ctrl.php +++ b/inc/users/registration.ctrl.php @@ -13,7 +13,7 @@ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); // Check minimum permission: -$current_User->check_perm( 'users', 'view', true ); +check_user_perm( 'users', 'view', true ); $AdminUI->set_path( 'users', 'usersettings', 'registration' ); @@ -26,7 +26,7 @@ $Session->assert_received_crumb( 'registration' ); // Check permission: - $current_User->check_perm( 'users', 'edit', true ); + check_user_perm( 'users', 'edit', true ); // keep old newusers_canregister setting value to check if we need to invalidate pagecaches $old_newusers_canregister = $Settings->get( 'newusers_canregister' ); diff --git a/inc/users/settings.ctrl.php b/inc/users/settings.ctrl.php index 83543ab9575..352f0d4b974 100644 --- a/inc/users/settings.ctrl.php +++ b/inc/users/settings.ctrl.php @@ -6,7 +6,7 @@ $AdminUI->set_path( 'users', 'usersettings', 'usersettings' ); -$current_User->check_perm( 'users', 'view', true ); +check_user_perm( 'users', 'view', true ); param_action(); @@ -17,7 +17,7 @@ $Session->assert_received_crumb( 'usersettings' ); // Check permission: - $current_User->check_perm( 'users', 'edit', true ); + check_user_perm( 'users', 'edit', true ); // Session settings $Settings->set( 'redirect_to_after_login', param( 'redirect_to_after_login', 'url', '' ) ); diff --git a/inc/users/user.ctrl.php b/inc/users/user.ctrl.php index 93c2d8a748b..a1f6aef9f3a 100644 --- a/inc/users/user.ctrl.php +++ b/inc/users/user.ctrl.php @@ -29,7 +29,7 @@ /** * @global boolean true, if user is only allowed to edit his profile */ -$user_profile_only = ! $current_User->check_perm( 'users', 'view' ); +$user_profile_only = ! check_user_perm( 'users', 'view' ); if( $user_profile_only ) { // User has no permissions to view: he can only edit his profile @@ -49,7 +49,7 @@ if( $action == 'new' ) { // Check permission, only admins can create new user: - $current_User->check_perm( 'users', 'edit', true ); + check_user_perm( 'users', 'edit', true ); } /* @@ -461,7 +461,7 @@ { // The user is updated if( ( $user_tab == 'admin' ) && ( $edited_User->ID == $current_User->ID ) ) { // an admin user has edited his own admin preferences - if( $current_User->check_status( 'is_closed' ) ) + if( check_user_status( 'is_closed' ) ) { // an admin user has changed his own status to closed, logout the user logout(); header_redirect( $baseurl, 303 ); @@ -579,7 +579,7 @@ $Session->assert_received_crumb( 'user' ); // Check edit permissions: - $current_User->check_perm( 'emails', 'edit', true ); + check_user_perm( 'emails', 'edit', true ); if( param( 'confirm', 'integer', 0 ) ) { // confirmed @@ -601,7 +601,7 @@ $Session->assert_received_crumb( 'user' ); // Check edit permissions: - $current_User->check_perm( 'emails', 'edit', true ); + check_user_perm( 'emails', 'edit', true ); if( param( 'confirm', 'integer', 0 ) ) { // confirmed @@ -777,7 +777,7 @@ $Session->assert_received_crumb( 'user' ); // Check edit permissions: - $current_User->check_perm( 'users', 'edit', true ); + check_user_perm( 'users', 'edit', true ); if( $edited_User->ID == $current_User->ID || $edited_User->ID == 1 ) { // Don't delete a logged in user @@ -818,7 +818,7 @@ if( param( 'delete_comments', 'integer', 0 ) ) { // Delete the comments // Count even recycled comments only if current User has global editall blogs permission, because only those users can delete trashed comments - $comments_created = $edited_User->get_num_comments( '', $current_User->check_perm( 'blogs', 'eidtall', false ) ); + $comments_created = $edited_User->get_num_comments( '', check_user_perm( 'blogs', 'eidtall', false ) ); if( $comments_created > 0 && $edited_User->delete_comments() ) { // The comments were deleted successfully $result_message = ( $comments_created == 1 ) ? TB_('1 comment was deleted.') : sprintf( TB_('%s comments were deleted.'), $comments_created ); @@ -961,7 +961,7 @@ case 'profile': $AdminUI->breadcrumbpath_add( TB_('Profile'), '?ctrl=user&user_ID='.$edited_User->ID.'&user_tab='.$user_tab ); init_userfields_js( 'rsc_url', $AdminUI->get_template( 'tooltip_plugin' ) ); - require_js( '#jcrop#', 'rsc_url' ); + require_js_defer( '#jcrop#', 'rsc_url' ); require_css( '#jcrop_css#', 'rsc_url' ); // Set an url for manual page: @@ -982,7 +982,7 @@ // Set an url for manual page: $AdminUI->set_page_manual_link( 'user-profile-picture-tab' ); } - require_js( '#jcrop#', 'rsc_url' ); + require_js_defer( '#jcrop#', 'rsc_url' ); require_css( '#jcrop_css#', 'rsc_url' ); break; case 'social': @@ -1253,7 +1253,7 @@ case 'delete_all_messages': $messages_count = $edited_User->get_num_messages( 'sent' ); - if( $messages_count > 0 && $current_User->check_perm( 'perm_messaging', 'abuse' ) ) + if( $messages_count > 0 && check_user_perm( 'perm_messaging', 'abuse' ) ) { // Display a confirm message if current user can delete the messages sent by the edited user $confirm_message = sprintf( TB_('Delete %d private messages sent by the user?'), $messages_count ); } @@ -1261,7 +1261,7 @@ case 'delete_all_received_messages': $messages_count = $edited_User->get_num_messages( 'received' ); - if( $messages_count > 0 && $current_User->check_perm( 'perm_messaging', 'abuse' ) ) + if( $messages_count > 0 && check_user_perm( 'perm_messaging', 'abuse' ) ) { // Display a confirm message if curent user can delete the messages sent by the edited user $confirm_message = sprintf( TB_('Delete %d private messages received by the user?'), $messages_count ); } @@ -1280,12 +1280,12 @@ { // User can NOT delete admin and own account: $confirm_messages = array(); $sent_emails_count = $edited_User->get_num_sent_emails(); - if( $sent_emails_count > 0 && $current_User->check_perm( 'emails', 'edit' ) ) + if( $sent_emails_count > 0 && check_user_perm( 'emails', 'edit' ) ) { // Display a confirm message if current user can delete at least one email sent log of the edited user: $confirm_messages[] = array( sprintf( TB_('%d emails sent to the user'), $sent_emails_count ), 'warning' ); } $email_returns_count = $edited_User->get_num_email_returns(); - if( $email_returns_count > 0 && $current_User->check_perm( 'emails', 'edit' ) ) + if( $email_returns_count > 0 && check_user_perm( 'emails', 'edit' ) ) { // Display a confirm message if current user can delete at least one email return of the edited user: $confirm_messages[] = array( sprintf( TB_('%d email returns from the user\'s email address'), $email_returns_count ), 'warning' ); } @@ -1309,7 +1309,7 @@ $confirm_messages[] = array( sprintf( TB_('%s comments posted by the user'), $edited_User->get_num_comments( '', true ) ), 'warning' ); } $messages_count = $edited_User->get_num_messages(); - if( $messages_count > 0 && $current_User->check_perm( 'perm_messaging', 'abuse' ) ) + if( $messages_count > 0 && check_user_perm( 'perm_messaging', 'abuse' ) ) { // Display a confirm message if current user can delete the messages sent by the edited user $confirm_messages[] = array( sprintf( TB_('%d private messages sent by the user'), $messages_count ), 'warning' ); } @@ -1369,7 +1369,7 @@ if( $display_mode != 'js') { - require_js( '#jcrop#', 'rsc_url' ); + require_js_defer( '#jcrop#', 'rsc_url' ); require_css( '#jcrop_css#', 'rsc_url' ); $AdminUI->disp_payload_begin(); } diff --git a/inc/users/userfields.ctrl.php b/inc/users/userfields.ctrl.php index 1c30377228f..ca448e41c56 100644 --- a/inc/users/userfields.ctrl.php +++ b/inc/users/userfields.ctrl.php @@ -15,13 +15,8 @@ // Load Userfield class: load_class( 'users/model/_userfield.class.php', 'Userfield' ); -/** - * @var User - */ -global $current_User; - // Check minimum permission: -$current_User->check_perm( 'users', 'view', true ); +check_user_perm( 'users', 'view', true ); // Set options path: $AdminUI->set_path( 'users', 'usersettings', 'userfields' ); @@ -47,7 +42,7 @@ case 'new': // Check permission: - $current_User->check_perm( 'users', 'edit', true ); + check_user_perm( 'users', 'edit', true ); if( ! isset($edited_Userfield) ) { // We don't have a model to use, start with blank object: @@ -62,7 +57,7 @@ case 'edit': // Check permission: - $current_User->check_perm( 'users', 'edit', true ); + check_user_perm( 'users', 'edit', true ); // Make sure we got an ufdf_ID: param( 'ufdf_ID', 'integer', true ); @@ -78,7 +73,7 @@ $Session->assert_received_crumb( 'userfield' ); // Check permission: - $current_User->check_perm( 'users', 'edit', true ); + check_user_perm( 'users', 'edit', true ); // load data from request if( $edited_Userfield->load_from_Request() ) @@ -120,7 +115,7 @@ $Session->assert_received_crumb( 'userfield' ); // Check permission: - $current_User->check_perm( 'users', 'edit', true ); + check_user_perm( 'users', 'edit', true ); // Make sure we got an ufdf_ID: param( 'ufdf_ID', 'integer', true ); @@ -149,7 +144,7 @@ $Session->assert_received_crumb( 'userfield' ); // Check permission: - $current_User->check_perm( 'users', 'edit', true ); + check_user_perm( 'users', 'edit', true ); // Make sure we got an ufdf_ID: param( 'ufdf_ID', 'integer', true ); @@ -183,7 +178,7 @@ $Session->assert_received_crumb( 'userfield' ); // Check permission: - $current_User->check_perm( 'users', 'edit', true ); + check_user_perm( 'users', 'edit', true ); // Make sure we got an ufdf_ID: param( 'ufdf_ID', 'integer', true ); diff --git a/inc/users/userfieldsgroups.ctrl.php b/inc/users/userfieldsgroups.ctrl.php index 9d0dca2b1d7..6587e96f942 100644 --- a/inc/users/userfieldsgroups.ctrl.php +++ b/inc/users/userfieldsgroups.ctrl.php @@ -15,13 +15,8 @@ // Load Userfield class: load_class( 'users/model/_userfieldgroup.class.php', 'UserfieldGroup' ); -/** - * @var User - */ -global $current_User; - // Check minimum permission: -$current_User->check_perm( 'users', 'view', true ); +check_user_perm( 'users', 'view', true ); // Set options path: $AdminUI->set_path( 'users', 'usersettings', 'userfields' ); @@ -47,7 +42,7 @@ case 'new': // Check permission: - $current_User->check_perm( 'users', 'edit', true ); + check_user_perm( 'users', 'edit', true ); if( ! isset($edited_UserfieldGroup) ) { // We don't have a model to use, start with blank object: @@ -62,7 +57,7 @@ case 'edit': // Check permission: - $current_User->check_perm( 'users', 'edit', true ); + check_user_perm( 'users', 'edit', true ); // Make sure we got an ufgp_ID: param( 'ufgp_ID', 'integer', true ); @@ -78,7 +73,7 @@ $Session->assert_received_crumb( 'userfieldgroup' ); // Check permission: - $current_User->check_perm( 'users', 'edit', true ); + check_user_perm( 'users', 'edit', true ); // load data from request if( $edited_UserfieldGroup->load_from_Request() ) @@ -116,7 +111,7 @@ $Session->assert_received_crumb( 'userfieldgroup' ); // Check permission: - $current_User->check_perm( 'users', 'edit', true ); + check_user_perm( 'users', 'edit', true ); // Make sure we got an ufgp_ID: param( 'ufgp_ID', 'integer', true ); @@ -145,7 +140,7 @@ $Session->assert_received_crumb( 'userfieldgroup' ); // Check permission: - $current_User->check_perm( 'users', 'edit', true ); + check_user_perm( 'users', 'edit', true ); // Make sure we got an ufgp_ID: param( 'ufgp_ID', 'integer', true ); diff --git a/inc/users/users.ctrl.php b/inc/users/users.ctrl.php index 0c52a6d6075..6205639be56 100644 --- a/inc/users/users.ctrl.php +++ b/inc/users/users.ctrl.php @@ -32,7 +32,7 @@ $AdminUI->set_path( 'users', $tab == 'stats' ? 'stats' : 'users', $tab3 == 'duplicates' ? 'duplicates' : 'list' ); -if( !$current_User->check_perm( 'users', 'view' ) ) +if( ! check_user_perm( 'users', 'view' ) ) { // User has no permissions to view: he can only edit his profile if( isset($user_ID) && $user_ID != $current_User->ID ) @@ -65,7 +65,7 @@ } elseif( $action == 'list' ) { // 'list' is default, $user_ID given - if( $user_ID == $current_User->ID || $current_User->check_perm( 'users', 'edit' ) ) + if( $user_ID == $current_User->ID || check_user_perm( 'users', 'edit' ) ) { $action = 'edit'; } @@ -78,7 +78,7 @@ if( $action != 'list' ) { // check edit permissions - if( ! $current_User->check_perm( 'users', 'edit' ) + if( ! check_user_perm( 'users', 'edit' ) && $edited_User->ID != $current_User->ID ) { // user is only allowed to _view_ other user's profiles $Messages->add( TB_('You have no permission to edit other users!'), 'error' ); @@ -335,7 +335,7 @@ $Session->assert_received_crumb( 'users' ); // Check required permission - $current_User->check_perm( 'users', 'edit', true ); + check_user_perm( 'users', 'edit', true ); // get the type of the removable sender customization $type = param( 'type', 'string', true ); @@ -385,7 +385,7 @@ case 'campaign': // Select the recipients for email campaign: - $current_User->check_perm( 'emails', 'edit', true ); + check_user_perm( 'emails', 'edit', true ); // Memorize action param to keep newsletter mode on change filters: memorize_param( 'action', 'string', true, $action ); @@ -419,7 +419,7 @@ $Session->assert_received_crumb( 'users' ); // Check permission: - $current_User->check_perm( 'options', 'view', true ); + check_user_perm( 'options', 'view', true ); param( 'autm_ID', 'integer', true ); param( 'enlt_ID', 'integer', true ); @@ -450,7 +450,7 @@ $Session->assert_received_crumb( 'users' ); // Check permission: - $current_User->check_perm( 'users', 'edit', true ); + check_user_perm( 'users', 'edit', true ); param( 'add_user_tags', 'string', '' ); param( 'remove_user_tags', 'string', '' ); @@ -486,7 +486,7 @@ $Session->assert_received_crumb( 'users' ); // Check permission: - $current_User->check_perm( 'users', 'edit', true ); + check_user_perm( 'users', 'edit', true ); param( 'account_status', 'string', '' ); @@ -527,7 +527,7 @@ $Session->assert_received_crumb( 'users' ); // Check permission: - $current_User->check_perm( 'users', 'edit', true ); + check_user_perm( 'users', 'edit', true ); $primary_grp_ID = param( 'grp_ID', 'integer' ); $add_secondary_grp_ID = param( 'add_secondary_grp_ID', 'integer' ); @@ -643,7 +643,7 @@ $Session->assert_received_crumb( 'users' ); // Check permission: - $current_User->check_perm( 'users', 'edit', true ); + check_user_perm( 'users', 'edit', true ); $users = explode( ',', param( 'users', 'string' ) ); @@ -693,7 +693,7 @@ $Session->assert_received_crumb( 'users' ); // Check permission: - $current_User->check_perm( 'users', 'view', true ); + check_user_perm( 'users', 'view', true ); load_class( 'users/model/_userlist.class.php', 'UserList' ); $UserList = new UserList( 'admin' ); @@ -743,7 +743,7 @@ $Session->assert_received_crumb( 'users' ); // Check permission: - $current_User->check_perm( 'users', 'view', true ); + check_user_perm( 'users', 'view', true ); // Do export: load_funcs( 'pro_only/model/_pro_user.funcs.php' ); @@ -766,50 +766,21 @@ $Session->assert_received_crumb( 'users' ); // Check permission: - $current_User->check_perm( 'users', 'edit', true ); + check_user_perm( 'users', 'edit', true ); - set_max_execution_time( 0 ); - - // Group Id - param( 'grp_ID', 'integer', true ); - param_check_number( 'grp_ID', TB_('Please select a group'), true ); - $GroupCache = & get_GroupCache(); - $Group = & $GroupCache->get_by_ID( $grp_ID ); - - param( 'on_duplicate_login', 'integer', true ); - param( 'on_duplicate_email', 'integer', true ); - - // CSV File - $import_file = param( 'import_file', 'string', '' ); - if( empty( $import_file ) ) - { // File is not selected: - $Messages->add( TB_('Please select a CSV file to import.'), 'error' ); - } - else if( ! preg_match( '/\.csv$/i', $import_file ) ) - { // Extension is incorrect - $Messages->add( sprintf( TB_('«%s» has an unrecognized extension.'), basename( $import_file ) ), 'error' ); - } - - if( param_errors_detected() ) - { // Some errors are exist, Stop the importing: - $action = 'csv'; - break; - } - - // Import users from CSV file: + // Do import: load_funcs( 'pro_only/model/_pro_user.funcs.php' ); - $count_users = pro_import_users( $grp_ID, $on_duplicate_login, $on_duplicate_email, $import_file ); + $import_operation = pro_import_users(); - if( $count_users === false ) + if( $import_operation === false ) { // Some errors are exist, Stop the importing: $action = 'csv'; break; } - - $Messages->add( sprintf( TB_('%d users have been added and %d users have been updated for primary group %s.'), - $count_users['inserted'], $count_users['updated'], $Group->get_name() ), 'success' ); - // Redirect so that a reload doesn't write to the DB twice: - header_redirect( $admin_url.'?ctrl=users', 303 ); // Will EXIT + else + { + header_redirect( $admin_url.'?ctrl=users', 303 ); // Will EXIT + } break; case 'save_default_filters': @@ -819,7 +790,7 @@ $Session->assert_received_crumb( 'users' ); // Check permission: - $current_User->check_perm( 'users', 'edit', true ); + check_user_perm( 'users', 'edit', true ); $filters = array(); for( $i = 1; $i <= 10; $i++ ) @@ -845,7 +816,7 @@ } // Used for autocomplete user fields in filter "Specific criteria" or to highlight user level cell on change -require_js( '#jqueryUI#' ); +require_js_defer( '#jqueryUI#' ); require_css( '#jqueryUI_css#' ); // We might delegate to this action from above: @@ -894,9 +865,9 @@ $AdminUI->breadcrumbpath_add( TB_('List'), '?ctrl=users' ); $AdminUI->top_block = get_user_quick_search_form(); - if( $current_User->check_perm( 'users', 'moderate' ) ) + if( check_user_perm( 'users', 'moderate' ) ) { // Include to edit user level - require_js( 'jquery/jquery.jeditable.js', 'rsc_url' ); + require_js_defer( 'customized:jquery/jeditable/jquery.jeditable.js', 'rsc_url' ); } load_funcs( 'regional/model/_regional.funcs.php' ); diff --git a/inc/users/usertags.ctrl.php b/inc/users/usertags.ctrl.php index 65d6a56b3b4..ea16aca9851 100644 --- a/inc/users/usertags.ctrl.php +++ b/inc/users/usertags.ctrl.php @@ -21,7 +21,7 @@ global $current_User; // Check minimum permission: -$current_User->check_perm( 'options', 'view', true ); +check_user_perm( 'options', 'view', true ); $AdminUI->set_path( 'users', 'usertags' ); @@ -49,14 +49,14 @@ case 'new': // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); $edited_UserTag = new UserTag(); break; case 'edit': // Check permission: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); break; case 'create': @@ -67,7 +67,7 @@ $Session->assert_received_crumb( 'usertag' ); // Check that current user has permission to create tags: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // load data from request if( $edited_UserTag->load_from_Request() ) @@ -90,7 +90,7 @@ $Session->assert_received_crumb( 'usertag' ); // Check that current user has permission to edit tags: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure we got an tag_ID: param( 'utag_ID', 'integer', true ); @@ -116,7 +116,7 @@ $Session->assert_received_crumb( 'usertag' ); // Check that current user has permission to edit tags: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); // Make sure we got an tag_ID: param( 'utag_ID', 'integer', true ); @@ -148,7 +148,7 @@ $Session->assert_received_crumb( 'usertag' ); // Check that current user has permission to edit tags: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); $user_ID = param( 'user_ID', 'integer', 0, true ); @@ -182,7 +182,7 @@ $Session->assert_received_crumb( 'usertag' ); // Check that current user has permission to edit tags: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); $old_tag_ID = param( 'old_tag_ID', 'integer', 0, true ); @@ -238,7 +238,7 @@ $Session->assert_received_crumb( 'usertag' ); // Check that current user has permission to edit tags: - $current_User->check_perm( 'options', 'edit', true ); + check_user_perm( 'options', 'edit', true ); $DB->query( 'DELETE T_users__usertag FROM T_users__usertag LEFT JOIN T_users ON uutg_user_ID = user_ID diff --git a/inc/users/views/_account_close_setting.form.php b/inc/users/views/_account_close_setting.form.php index bf9e73fcc4c..56a34de9d2a 100644 --- a/inc/users/views/_account_close_setting.form.php +++ b/inc/users/views/_account_close_setting.form.php @@ -13,10 +13,6 @@ */ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); -/** - * @var User - */ -global $current_User; /** * @var GeneralSettings */ @@ -49,7 +45,7 @@ // -------------------------------------------- -if( $current_User->check_perm( 'users', 'edit' ) ) +if( check_user_perm( 'users', 'edit' ) ) { $Form->end_form( array( array( 'submit', 'submit', TB_('Save Changes!'), 'SaveButton' ) ) ); } diff --git a/inc/users/views/_display.form.php b/inc/users/views/_display.form.php index b284e4732c4..f72d0bcf4e8 100644 --- a/inc/users/views/_display.form.php +++ b/inc/users/views/_display.form.php @@ -13,10 +13,6 @@ */ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); -/** - * @var User - */ -global $current_User; /** * @var GeneralSettings */ @@ -153,7 +149,7 @@ // -------------------------------------------- -if( $current_User->check_perm( 'users', 'edit' ) ) +if( check_user_perm( 'users', 'edit' ) ) { $Form->end_form( array( array( 'submit', 'submit', TB_('Save Changes!'), 'SaveButton' ) ) ); } diff --git a/inc/users/views/_group.view.php b/inc/users/views/_group.view.php index c4543b7b2af..002e8004194 100644 --- a/inc/users/views/_group.view.php +++ b/inc/users/views/_group.view.php @@ -48,7 +48,7 @@ /* * Table icons: */ -if( $current_User->check_perm( 'users', 'edit', false ) ) +if( check_user_perm( 'users', 'edit', false ) ) { // create new group link $Results->global_icon( T_('Create a new group...'), 'new', '?ctrl=groups&action=new', T_('Add group').' »', 3, 4, array( 'class' => 'action_icon btn-primary' ) ); } @@ -62,7 +62,7 @@ ); // Check if user can edit users -$has_perm_users_edit = $current_User->check_perm( 'users', 'edit', false ); +$has_perm_users_edit = check_user_perm( 'users', 'edit', false ); $Results->cols[] = array( 'th' => T_('Name'), @@ -149,10 +149,10 @@ function grp_row_backoffice( $backoffice_access ) function grp_actions( & $row ) { - global $usedgroups, $Settings, $current_User; + global $usedgroups, $Settings; $r = ''; - if( $current_User->check_perm( 'users', 'edit', false ) ) + if( check_user_perm( 'users', 'edit', false ) ) { $r = action_icon( T_('Edit this group...'), 'edit', regenerate_url( 'ctrl,action', 'ctrl=groups&action=edit&grp_ID='.$row->grp_ID ) ); @@ -179,7 +179,7 @@ function grp_actions( & $row ) // Display results: $Results->display(); -if( $current_User->check_perm( 'users', 'edit', false ) ) +if( check_user_perm( 'users', 'edit', false ) ) { // If user can edit the users - Init js to edit group level by AJAX $group_levels = array(); for( $l = 0; $l <= 10; $l++ ) diff --git a/inc/users/views/_invitation.view.php b/inc/users/views/_invitation.view.php index e6c8e7b767e..94160e5163f 100644 --- a/inc/users/views/_invitation.view.php +++ b/inc/users/views/_invitation.view.php @@ -32,7 +32,7 @@ /* * Table icons: */ -if( $current_User->check_perm( 'users', 'edit', false ) ) +if( check_user_perm( 'users', 'edit', false ) ) { // create new group link $Results->global_icon( T_('Create a new invitation code...'), 'new', '?ctrl=invitations&action=new', T_('Add invitation code').' »', 3, 4, array( 'class' => 'action_icon btn-primary' ) ); } @@ -48,7 +48,7 @@ $Results->cols[] = array( 'th' => T_('Code').' | '.T_('Link'), 'order' => 'ivc_code', - 'td' => $current_User->check_perm( 'users', 'edit', false ) + 'td' => check_user_perm( 'users', 'edit', false ) ? '$ivc_code$' : '$ivc_code$', ); @@ -101,7 +101,7 @@ function ivc_group( $group_ID, $group_name, $group_level ) 'td' => '$ivc_source$', ); -if( $current_User->check_perm( 'users', 'edit', false ) ) +if( check_user_perm( 'users', 'edit', false ) ) { function ivc_actions( & $row ) { diff --git a/inc/users/views/_organization.form.php b/inc/users/views/_organization.form.php index e8b056d1a48..6dade3e30e0 100644 --- a/inc/users/views/_organization.form.php +++ b/inc/users/views/_organization.form.php @@ -41,7 +41,7 @@ $Form->hiddens_by_key( get_memorized( 'action' ) ); // (this allows to come back to the right list order & page) - if( $current_User->check_perm( 'orgs', 'edit' ) ) + if( check_user_perm( 'orgs', 'edit' ) ) { // Allow to change an owner if current user has a permission to edit all polls: $Form->username( 'org_owner_login', $edited_Organization->get_owner_User(), TB_('Owner'), '', '', array( 'required' => true ) ); } @@ -68,7 +68,7 @@ ), TB_('Role in organization'), true ); $buttons = array(); -if( $current_User->check_perm( 'orgs', 'edit', false, $edited_Organization ) ) +if( check_user_perm( 'orgs', 'edit', false, $edited_Organization ) ) { // Display a button to update the poll question only if current user has a permission: if( $creating ) { diff --git a/inc/users/views/_organization.view.php b/inc/users/views/_organization.view.php index 83263c23816..69628a7cf05 100644 --- a/inc/users/views/_organization.view.php +++ b/inc/users/views/_organization.view.php @@ -45,7 +45,7 @@ /* * Table icons: */ -if( $current_User->check_perm( 'orgs', 'create', false ) ) +if( check_user_perm( 'orgs', 'create', false ) ) { // create new group link $Results->global_icon( T_('Create a new organization...'), 'new', '?ctrl=organizations&action=new', T_('Add organization').' »', 3, 4, array( 'class' => 'action_icon btn-primary' ) ); } @@ -75,9 +75,7 @@ function filter_organizations( & $Form ) function org_td_name( & $Organization ) { - global $current_User; - - if( $current_User->check_perm( 'orgs', 'view', false, $Organization ) ) + if( check_user_perm( 'orgs', 'view', false, $Organization ) ) { global $admin_url; return ''.$Organization->get( 'name' ).''; @@ -122,17 +120,15 @@ function org_td_owner( & $Organization ) function org_td_actions( & $Organization ) { - global $current_User; - $r = ''; - $perm_org_edit = $current_User->check_perm( 'orgs', 'edit', false, $Organization ); + $perm_org_edit = check_user_perm( 'orgs', 'edit', false, $Organization ); if( $perm_org_edit ) { $r .= action_icon( T_('Edit this organization...'), 'edit', regenerate_url( 'ctrl,action', 'ctrl=organizations&org_ID='.$Organization->ID.'&action=edit&filter=refresh' ) ); } - if( $current_User->check_perm( 'orgs', 'create', false ) ) + if( check_user_perm( 'orgs', 'create', false ) ) { $r .= action_icon( T_('Duplicate this organization...'), 'copy', regenerate_url( 'ctrl,action', 'ctrl=organizations&org_ID='.$Organization->ID.'&action=new' ) ); diff --git a/inc/users/views/_organization_user.form.php b/inc/users/views/_organization_user.form.php index 4729d662675..34c80811eb1 100644 --- a/inc/users/views/_organization_user.form.php +++ b/inc/users/views/_organization_user.form.php @@ -44,7 +44,7 @@ $Form->text_input( 'priority', '', 32, TB_('Order'), '', array( 'maxlength' => 255, 'type' => 'number' ) ); $buttons = array(); -if( $current_User->check_perm( 'orgs', 'edit', false, $edited_Organization ) ) +if( check_user_perm( 'orgs', 'edit', false, $edited_Organization ) ) { // Display a button to update the poll question only if current user has a permission: $buttons[] = array( 'submit', 'actionArray[link_user]', TB_('Add'), 'SaveButton' ); } diff --git a/inc/users/views/_organization_user_edit.form.php b/inc/users/views/_organization_user_edit.form.php index 2e1926721db..5c51933b050 100644 --- a/inc/users/views/_organization_user_edit.form.php +++ b/inc/users/views/_organization_user_edit.form.php @@ -53,7 +53,7 @@ $Form->info_field( TB_('Role'), $org_data[$org_ID]['role'] ); } - if( $edited_Organization->owner_user_ID == $current_User->ID || $current_User->check_perm( 'orgs', 'edit', false, $edited_Organization ) ) + if( $edited_Organization->owner_user_ID == $current_User->ID || check_user_perm( 'orgs', 'edit', false, $edited_Organization ) ) { // Display edit field if current user has a permission to edit order: $Form->text_input( 'priority', $org_data[$org_ID]['priority'], 10, TB_('Order'), '', array( 'type' => 'number', 'min' => -2147483648, 'max' => 2147483647 ) ); } @@ -63,7 +63,7 @@ } $buttons = array(); -if( $current_User->check_perm( 'orgs', 'edit', false, $edited_Organization ) ) +if( check_user_perm( 'orgs', 'edit', false, $edited_Organization ) ) { // Display a button to update the poll question only if current user has a permission: $buttons[] = array( 'submit', 'actionArray[link_user]', TB_('Edit'), 'SaveButton' ); } diff --git a/inc/users/views/_organization_user_remove.form.php b/inc/users/views/_organization_user_remove.form.php index 65a7cec43a7..75b8ca8c7f7 100644 --- a/inc/users/views/_organization_user_remove.form.php +++ b/inc/users/views/_organization_user_remove.form.php @@ -31,7 +31,7 @@ echo '

    '.sprintf( TB_('This will remove %s from the organization. Would you like to continue?'), $edited_User->get( 'preferredname' ) ).'

    '; $buttons = array(); -if( $current_User->check_perm( 'orgs', 'edit', false, $edited_Organization ) ) +if( check_user_perm( 'orgs', 'edit', false, $edited_Organization ) ) { // Display a button to confirm removal of user from the organization $buttons[] = array( 'submit', 'actionArray[unlink_user]', TB_('Continue'), 'SaveButton' ); } diff --git a/inc/users/views/_registration.form.php b/inc/users/views/_registration.form.php index f0ece0e0c25..a2a76f68fe8 100644 --- a/inc/users/views/_registration.form.php +++ b/inc/users/views/_registration.form.php @@ -12,10 +12,6 @@ */ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); -/** - * @var User - */ -global $current_User; /** * @var GeneralSettings */ @@ -23,7 +19,7 @@ global $collections_Module, $Plugins; -global $baseurl, $admin_url, $current_User, $Blog; +global $baseurl, $admin_url, $Blog; $Form = new Form( NULL, 'settings_checkchanges' ); $Form->begin_form( 'fform', '', @@ -90,7 +86,7 @@ $TemplateCache = & get_TemplateCache(); $TemplateCache->load_by_context( $context ); - $template_input_suffix = ( $current_User->check_perm( 'options', 'edit' ) ? ' ' + $template_input_suffix = ( check_user_perm( 'options', 'edit' ) ? ' ' .action_icon( '', 'edit', $admin_url.'?ctrl=templates&context='.$context.( isset( $Blog ) ? '&blog='.$Blog->ID : '' ), NULL, NULL, NULL, array( 'onclick' => 'return b2template_list_highlight( this )' ), array( 'title' => TB_('Manage templates').'...' ) ) : '' ); $Form->select_input_array( 'registration_master_template', $Settings->get( 'registration_master_template' ), $TemplateCache->get_code_option_array(), TB_('Registration master template'), NULL, array( 'input_suffix' => $template_input_suffix ) ); @@ -258,7 +254,7 @@ // -------------------------------------------- -if( $current_User->check_perm( 'users', 'edit' ) ) +if( check_user_perm( 'users', 'edit' ) ) { $Form->end_form( array( array( 'submit', 'submit', TB_('Save Changes!'), 'SaveButton' ) ) ); } diff --git a/inc/users/views/_settings.form.php b/inc/users/views/_settings.form.php index 0b51b42a6bf..ed928707371 100644 --- a/inc/users/views/_settings.form.php +++ b/inc/users/views/_settings.form.php @@ -6,12 +6,8 @@ * @var instance of GeneralSettings class */ global $Settings; -/** - * @var instance of User class - */ -global $current_User; -$current_User->check_perm( 'users', 'view', true ); +check_user_perm( 'users', 'view', true ); $Form = new Form( NULL, 'usersettings_checkchanges' ); @@ -110,7 +106,7 @@ $Form->end_fieldset(); -if( $current_User->check_perm( 'users', 'edit' ) ) +if( check_user_perm( 'users', 'edit' ) ) { $Form->buttons( array( array( 'submit', 'submit', TB_('Save Changes!'), 'SaveButton' ) ) ); } diff --git a/inc/users/views/_user_activity.view.php b/inc/users/views/_user_activity.view.php index 22355896fa3..10e8f28157b 100644 --- a/inc/users/views/_user_activity.view.php +++ b/inc/users/views/_user_activity.view.php @@ -147,7 +147,7 @@ evo_flush(); -if( $action != 'view' && $current_User->ID != $edited_User->ID && $edited_User->ID != 1 && $current_User->check_perm( 'users', 'edit' ) ) +if( $action != 'view' && $current_User->ID != $edited_User->ID && $edited_User->ID != 1 && check_user_perm( 'users', 'edit' ) ) { // User can NOT delete admin and own account echo '
    '; echo action_icon( T_('Delete User and All his contributions'), 'delete', '?ctrl=user&user_tab=activity&action=delete_all_userdata&user_ID='.$edited_User->ID.'&'.url_crumb('user'), ' '.T_('Delete User and All his contributions'), 3, 4, array( 'class' => 'btn btn-danger' ) ); diff --git a/inc/users/views/_user_admin.form.php b/inc/users/views/_user_admin.form.php index a989cd1d6d1..662ca983bcc 100644 --- a/inc/users/views/_user_admin.form.php +++ b/inc/users/views/_user_admin.form.php @@ -97,7 +97,7 @@ $email_status = $edited_User->get_email_status(); $email_status_icon = '
    '.emadr_get_status_icon( $email_status ).'
    '; - if( $current_User->check_perm( 'users', 'edit' ) ) + if( check_user_perm( 'users', 'edit' ) ) { $Form->select_input_array( 'edited_email_status', $email_status, emadr_get_status_titles(), ''.TB_('Status').': '.$email_status_icon, '', array( 'force_keys_as_values' => true, 'background_color' => emadr_get_status_colors() ) ); } @@ -245,7 +245,7 @@ // Number of comments created by the edited User evo_flush(); // The following might take a while on systems with many comments // Get the number of edited User comments, but count recycled comments only if the user has global editall blogs permission - $comments_created_num = $edited_User->get_num_comments( '', $current_User->check_perm( 'blogs', 'editall', false ) ); + $comments_created_num = $edited_User->get_num_comments( '', check_user_perm( 'blogs', 'editall', false ) ); $comments_created = $comments_created_num; if( $comments_created > 0 ) { @@ -269,7 +269,7 @@ if( $messages_sent > 0 ) { $messages_sent .= ' - '.get_icon( 'magnifier', 'imgtag', array( 'title' => TB_('Go to user activity') ) ).''; - if( $current_User->check_perm( 'perm_messaging', 'abuse' ) ) + if( check_user_perm( 'perm_messaging', 'abuse' ) ) { $messages_sent .= ' - '.TB_('Go to abuse management').' »'; } @@ -280,7 +280,7 @@ } } $Form->info_field( '', $messages_sent ); - if( $messages_received > 0 && $current_User->check_perm( 'perm_messaging', 'abuse' ) ) + if( $messages_received > 0 && check_user_perm( 'perm_messaging', 'abuse' ) ) { $messages_received .= ' - '.get_icon( 'magnifier', 'imgtag', array( 'title' => TB_('Go to abuse management') ) ).''; } @@ -341,7 +341,7 @@ $user_ip_address.( empty( $user_ip_address ) ? '' : ' '.get_icon( 'magnifier' ).'' ) ); $Form->end_line( NULL, 'info' ); - if( $current_User->check_perm( 'spamblacklist', 'view' ) ) + if( check_user_perm( 'spamblacklist', 'view' ) ) { // User can view IP ranges // Get status and name of IP range $IPRangeCache = & get_IPRangeCache(); @@ -349,7 +349,7 @@ { // IP range exists in DB $iprange_status = $IPRange->get( 'status' ); $iprange_name = $IPRange->get_name(); - if( $current_User->check_perm( 'spamblacklist', 'view' ) ) + if( check_user_perm( 'spamblacklist', 'view' ) ) { // Display IP range as link to edit form if current user has the permissions: $iprange_name = ''.$iprange_name.''; } @@ -359,7 +359,7 @@ $iprange_status = ''; $iprange_name = ''; } - $perm_spamblacklist = $current_User->check_perm( 'spamblacklist', 'edit' ); + $perm_spamblacklist = check_user_perm( 'spamblacklist', 'edit' ); $Form->begin_line( TB_('IP range'), NULL, ( $perm_spamblacklist ? '' : 'info' ) ); $Form->info_field( '', $iprange_name ); $email_status_icon = '
    '.aipr_status_icon( $iprange_status ).'
    '; @@ -389,9 +389,9 @@ $Form->info_field( ''.TB_('Initial URI').': ', $UserSettings->get( 'initial_URI', $edited_User->ID ) ); $Form->end_line( NULL, 'info' ); - $perm_stat_edit = $current_User->check_perm( 'stats', 'edit' ); + $perm_stat_edit = check_user_perm( 'stats', 'edit' ); $initial_referer = $UserSettings->get( 'initial_referer', $edited_User->ID ); - $display_initial_referer = ( ! empty( $initial_referer ) && $current_User->check_perm( 'stats', 'list' ) ); + $display_initial_referer = ( ! empty( $initial_referer ) && check_user_perm( 'stats', 'list' ) ); $Form->begin_line( TB_('Initial referer'), NULL, ( $display_initial_referer && $perm_stat_edit ? '' : 'info' ) ); $Domain = & get_Domain_by_url( $initial_referer ); $initial_referer_formatted = format_to_output( $initial_referer ); @@ -485,7 +485,7 @@ } ); check_perm( 'users', 'edit' ) ) +if( check_user_perm( 'users', 'edit' ) ) { // START OF email status change script ?> var email_status_icons = new Array; @@ -535,7 +535,7 @@ check_perm( 'spamblacklist', 'edit' ) ) +if( check_user_perm( 'spamblacklist', 'edit' ) ) { // User can edit IP ranges ?> var iprange_status_icons = new Array; @@ -561,7 +561,7 @@ check_perm( 'stats', 'edit' ) ) +if( check_user_perm( 'stats', 'edit' ) ) { // User can edit Domain ?> var domain_status_icons = new Array; diff --git a/inc/users/views/_user_automation.form.php b/inc/users/views/_user_automation.form.php index b111b37e9e2..61f23181ea4 100644 --- a/inc/users/views/_user_automation.form.php +++ b/inc/users/views/_user_automation.form.php @@ -32,10 +32,6 @@ * @var the action destination of the form (NULL for pagenow) */ global $form_action; -/** - * @var instance of User class - */ -global $current_User; // Begin payload block: $this->disp_payload_begin(); diff --git a/inc/users/views/_user_avatar.form.php b/inc/users/views/_user_avatar.form.php index 8018cd990f7..816b6dee751 100644 --- a/inc/users/views/_user_avatar.form.php +++ b/inc/users/views/_user_avatar.form.php @@ -261,7 +261,7 @@ $more_content = ''; - if( $action != 'view' && $current_User->check_perm( 'files', 'view' ) ) + if( $action != 'view' && check_user_perm( 'files', 'view' ) ) { // If current user can edit this User: $more_content .= ''; $more_content .= TB_( 'Use the file manager to assign a new profile picture' ).''; diff --git a/inc/users/views/_user_deldata.form.php b/inc/users/views/_user_deldata.form.php index 6e78c59d310..23b14d73422 100644 --- a/inc/users/views/_user_deldata.form.php +++ b/inc/users/views/_user_deldata.form.php @@ -32,10 +32,6 @@ * @var the action destination of the form (NULL for pagenow) */ global $form_action; -/** - * @var instance of User class - */ -global $current_User; if( $display_mode != 'js' ) { @@ -79,7 +75,7 @@ $posts_created = $edited_User->get_num_posts(); // Get the number of comments created by the edited user, but count recycled comments only if user has global editall blogs permission - $comments_created = $edited_User->get_num_comments( '', $current_User->check_perm( 'blogs', 'editall', false ) ); + $comments_created = $edited_User->get_num_comments( '', check_user_perm( 'blogs', 'editall', false ) ); $messages_sent = $edited_User->get_num_messages( 'sent' ); $delete_options = array(); diff --git a/inc/users/views/_user_identity.form.php b/inc/users/views/_user_identity.form.php index 7f985596930..0b302cef114 100644 --- a/inc/users/views/_user_identity.form.php +++ b/inc/users/views/_user_identity.form.php @@ -77,7 +77,7 @@ ) ); // ------------- END OF PREV/NEXT USER LINKS ------------------- -$has_full_access = $current_User->check_perm( 'users', 'edit' ); +$has_full_access = check_user_perm( 'users', 'edit' ); $has_moderate_access = $current_User->can_moderate_user( $edited_User->ID ); $edited_user_perms = array( 'edited-user', 'edited-user-required' ); $new_user_creating = ( $edited_User->ID == 0 ); @@ -189,12 +189,14 @@ if( $edited_User->has_avatar() || count( $user_avatars ) ) { // If user uploaded at least one profile picture - $change_picture_title = TB_('Change').' »'; + $change_picture_text = T_('Change').' »'; + $change_picture_title = T_('Change profile picture').'...'; $change_picture_icon = 'edit'; } else { // If user has no profile picture yet - $change_picture_title = TB_('Upload now').' »'; + $change_picture_text = T_('Upload now').' »'; + $change_picture_title = T_('Upload profile picture').'...'; $change_picture_icon = 'move_up_green'; } @@ -202,23 +204,23 @@ $user_pictures = '
    ' .$edited_User->get_avatar_imgtag( 'crop-top-320x320', 'avatar', 'top', true, '', 'user', '160x160' ) .'
    ' - .action_icon( $change_picture_title, $change_picture_icon, get_user_settings_url( 'avatar', $edited_User->ID ), ' '.$change_picture_title, 3, 4 ); + .action_icon( $change_picture_title, $change_picture_icon, get_user_settings_url( 'avatar', $edited_User->ID ), ' '.$change_picture_text, 3, 4 ); if( $edited_User->has_avatar() && ( $avatar_Link = & $edited_User->get_avatar_Link() ) ) { // Display these actions only for existing avatar file $user_pictures .= '
    ' - .action_icon( TB_('No longer use this as main profile picture'), 'move_down', $remove_picture_url, ' '.TB_('No longer use this as main profile picture'), 3, 4 ).'
    ' + .action_icon( T_('No longer use this as main profile picture'), 'move_down', $remove_picture_url, ' '.T_('No longer use this as main profile picture'), 3, 4 ).'
    ' .$forbid_link - .action_icon( TB_('Delete this profile picture'), 'delete', $delete_picture_url, ' '.TB_('Delete this profile picture'), 3, 4, array( 'onclick' => 'return confirm(\''.TS_('Are you sure want to delete this picture?').'\');' ) ).'
    ' + .action_icon( T_('Delete this profile picture'), 'delete', $delete_picture_url, ' '.T_('Delete this profile picture'), 3, 4, array( 'onclick' => 'return confirm(\''.TS_('Are you sure want to delete this picture?').'\');' ) ).'
    ' .$edited_User->get_rotate_avatar_icons( $edited_User->avatar_file_ID, array( 'before' => '', 'after' => '
    ', - 'text' => ' '.TB_('Rotate'), + 'text' => ' '.T_('Rotate'), 'user_tab' => 'avatar', ) ) .$edited_User->get_crop_avatar_icon( $edited_User->avatar_file_ID, array( 'before' => '', 'after' => '', - 'text' => ' '.TB_('Crop'), + 'text' => ' '.T_('Crop'), 'user_tab' => 'avatar', 'onclick' => 'return user_crop_avatar( '.$edited_User->ID.', '.$edited_User->avatar_file_ID.', \'avatar\' )' ) ); @@ -413,7 +415,7 @@ if( ! empty( $org_ID ) ) { // $org_ID can be 0 for case when user didn't select an organization yet $user_Organization = & $OrganizationCache->get_by_ID( $org_ID ); - $perm_edit_orgs = $current_User->check_perm( 'orgs', 'edit', false, $user_Organization ); + $perm_edit_orgs = check_user_perm( 'orgs', 'edit', false, $user_Organization ); } // Display a button to remove user from organization @@ -731,278 +733,26 @@ function new_user_pass_visibility() $Form->end_form(); -?> - +expose_var_to_js( 'evo_user_identity_form_config', evo_json_encode( $user_identity_form_config ) ); - -check_perm( 'users', 'edit' ) ) + if( ! check_user_perm( 'users', 'edit' ) ) { // Show the limited list for moderators: $group_where_sql = 'grp_level < '.$current_User->get_Group()->get( 'level' ); } diff --git a/inc/users/views/_user_marketing.form.php b/inc/users/views/_user_marketing.form.php index 600765047b7..34b60d6facf 100644 --- a/inc/users/views/_user_marketing.form.php +++ b/inc/users/views/_user_marketing.form.php @@ -103,7 +103,7 @@ $Results->cols[] = array( 'th' => TB_('Automation'), 'order' => 'autm_name', - 'td' => ( $current_User->check_perm( 'options', 'edit' ) + 'td' => ( check_user_perm( 'options', 'edit' ) ? '$autm_name$' : '$autm_name$' ), ); diff --git a/inc/users/views/_user_password.form.php b/inc/users/views/_user_password.form.php index d68a645d15e..b96625761cc 100644 --- a/inc/users/views/_user_password.form.php +++ b/inc/users/views/_user_password.form.php @@ -94,7 +94,7 @@ $form_class = $params['form_class_user_pass']; } -$has_full_access = $current_User->check_perm( 'users', 'edit' ); +$has_full_access = check_user_perm( 'users', 'edit' ); $Form->begin_form( $form_class, $form_title, array( 'title' => ( isset( $form_text_title ) ? $form_text_title : $form_title ) ) ); @@ -153,12 +153,12 @@ // Display javascript password strength indicator bar display_password_indicator( array( - 'pass1-id' => 'edited_user_pass1', - 'pass2-id' => 'edited_user_pass2', - 'login-id' => 'edited_user_login', - 'field-width' => 165, + 'pass1_id' => 'edited_user_pass1', + 'pass2_id' => 'edited_user_pass2', + 'login_id' => 'edited_user_login', + 'field_width' => 165, ) ); // Display javascript code to edit password: display_password_js_edit(); -?> \ No newline at end of file +?> diff --git a/inc/users/views/_user_preferences.form.php b/inc/users/views/_user_preferences.form.php index 6c0dc7b0384..8ee2980b5b1 100644 --- a/inc/users/views/_user_preferences.form.php +++ b/inc/users/views/_user_preferences.form.php @@ -122,7 +122,7 @@ break; default: $multiple_sessions_field_hidden = false; - if( ( $multiple_sessions == 'adminset_default_no' || $multiple_sessions == 'adminset_default_yes' ) && !$current_User->check_perm( 'users', 'edit' ) ) + if( ( $multiple_sessions == 'adminset_default_no' || $multiple_sessions == 'adminset_default_yes' ) && ! check_user_perm( 'users', 'edit' ) ) { $multiple_sessions_field_disabled = true; } @@ -171,7 +171,7 @@ '', 1, $multiple_sessions_field_disabled ); } - if( ( $current_User->ID == $edited_User->ID ) || ( $current_User->check_perm( 'users', 'edit' ) ) ) + if( ( $current_User->ID == $edited_User->ID ) || ( check_user_perm( 'users', 'edit' ) ) ) { $Form->radio_input( 'edited_user_timeout_sessions', $timeout_sessions_selected, array( array( @@ -236,7 +236,7 @@ } if( $Settings->get( 'account_close_enabled' ) && isset( $Blog ) && - ( $current_User->ID == $edited_User->ID ) && ! $current_User->check_perm( 'users', 'edit', false ) ) + ( $current_User->ID == $edited_User->ID ) && ! check_user_perm( 'users', 'edit', false ) ) { // Display a linkt to close account // Admins cannot close own accounts from front office $Form->info( '', ''.TB_( 'I want to close my account...' ).'' ); diff --git a/inc/users/views/_user_register_finish.form.php b/inc/users/views/_user_register_finish.form.php index 5c46c83dfd9..0524661c4e6 100644 --- a/inc/users/views/_user_register_finish.form.php +++ b/inc/users/views/_user_register_finish.form.php @@ -91,7 +91,7 @@ if( ( empty( $reqID ) || $reqID != $Session->get( 'core.changepwd.request_id' ) ) && ( $edited_User->get( 'pass_driver' ) != 'nopass' && ( ! isset( $edited_User->previous_pass_driver ) || $edited_User->previous_pass_driver != 'nopass' ) ) ) { - if( ! $current_User->check_perm( 'users', 'edit' ) || $edited_User->ID == $current_User->ID ) + if( ! check_user_perm( 'users', 'edit' ) || $edited_User->ID == $current_User->ID ) { // Current user has no full access or editing his own password $Form->password_input( 'current_user_pass', '', 20, TB_('Current password'), array( 'maxlength' => 50, 'required' => ($edited_User->ID == 0), 'autocomplete'=>'off', 'style' => 'width:'.$params['register_field_width'].'px' ) ); } @@ -171,10 +171,10 @@ // Display javascript password strength indicator bar display_password_indicator( array( - 'pass1-id' => 'edited_user_pass1', - 'pass2-id' => 'edited_user_pass2', - 'login-id' => 'edited_user_login', - 'field-width' => $params['register_field_width'], + 'pass1_id' => 'edited_user_pass1', + 'pass2_id' => 'edited_user_pass2', + 'login_id' => 'edited_user_login', + 'field_width' => $params['register_field_width'], ) ); // Display javascript code to edit password: diff --git a/inc/users/views/_user_report.form.php b/inc/users/views/_user_report.form.php index 70e52ae2c23..af37999d558 100644 --- a/inc/users/views/_user_report.form.php +++ b/inc/users/views/_user_report.form.php @@ -32,10 +32,6 @@ * @var the action destination of the form (NULL for pagenow) */ global $form_action; -/** - * @var instance of User class - */ -global $current_User; if( $display_mode != 'js' ) { diff --git a/inc/users/views/_user_subscriptions.form.php b/inc/users/views/_user_subscriptions.form.php index ac76f4b01fc..53506a97cfd 100644 --- a/inc/users/views/_user_subscriptions.form.php +++ b/inc/users/views/_user_subscriptions.form.php @@ -186,7 +186,7 @@ } elseif( ( $emails_msgform == 'adminset' ) ) { // only administrator users can set and current User is in 'Administrators' group - $is_disabled_email_method = ( $disabled || ! $current_User->check_perm( 'users', 'edit' ) ); + $is_disabled_email_method = ( $disabled || ! check_user_perm( 'users', 'edit' ) ); $messaging_options[] = array( 'enable_email', 1, TB_( 'emails through a message form that will NOT reveal my email address.' ).get_admin_badge( 'user' ), $UserSettings->get( 'enable_email', $edited_User->ID ), $is_disabled_email_method, $email_messaging_note ); } elseif( ! empty( $email_messaging_note ) ) @@ -411,7 +411,7 @@ $post_subs = array(); $post_counter = 0; } - if( is_admin_page() && $current_User->check_perm( 'item_post!CURSTATUS', 'view', false, $Item ) ) + if( is_admin_page() && check_user_perm( 'item_post!CURSTATUS', 'view', false, $Item ) ) { // Link title to back-office if user has a permission $item_title = ''.format_to_output( $Item->get( 'title' ) ).''; } @@ -492,7 +492,7 @@ { // user is member of at least one collection $notify_options[ TB_('Posts') ][] = array( 'edited_user_notify_post_assignment', 1, TB_('a post was assigned to me.'), $UserSettings->get( 'notify_post_assignment', $edited_User->ID ), $disabled ); } - if( $current_User->check_perm( 'users', 'edit' ) ) + if( check_user_perm( 'users', 'edit' ) ) { // current User is an administrator $notify_options[ TB_('My account') ][] = array( 'edited_user_send_activation_reminder', 1, sprintf( TB_('my account was deactivated or is not activated for more than %s.').get_admin_badge( 'user' ), seconds_to_period( $Settings->get( 'activate_account_reminder_threshold' ) ) ), $UserSettings->get( 'send_activation_reminder', $edited_User->ID ), $disabled ); } @@ -515,7 +515,7 @@ $notify_options[ TB_('System maintenance') ][] = array( 'edited_user_notify_list_new_subscriber', 1, TB_('one of my Lists gets a new subscriber.'), $UserSettings->get( 'notify_list_new_subscriber', $edited_User->ID ), $disabled ); $notify_options[ TB_('System maintenance') ][] = array( 'edited_user_notify_list_lost_subscriber', 1, TB_('one of my Lists loses a subscriber.'), $UserSettings->get( 'notify_list_lost_subscriber', $edited_User->ID ), $disabled ); - if( $current_User->check_perm( 'users', 'edit' ) && $edited_User->check_perm( 'options', 'view' ) ) + if( check_user_perm( 'users', 'edit' ) && $edited_User->check_perm( 'options', 'view' ) ) { // current User is an administrator and the edited user has a permission to automations: $notify_options[ TB_('System maintenance') ][] = array( 'edited_user_notify_automation_owner', 1, TB_('one of my automations wants to notify me.'), $UserSettings->get( 'notify_automation_owner', $edited_User->ID ), $disabled ); } diff --git a/inc/users/views/_userfields.view.php b/inc/users/views/_userfields.view.php index cb3482d5e6e..3d3735cd4ae 100644 --- a/inc/users/views/_userfields.view.php +++ b/inc/users/views/_userfields.view.php @@ -122,8 +122,8 @@ function filter_userfields( & $Form ) /* * Group columns: */ -$group_td_colspan = $current_User->check_perm( 'users', 'edit', false ) ? -2 : 0; -if( $current_User->check_perm( 'users', 'edit' ) ) +$group_td_colspan = check_user_perm( 'users', 'edit', false ) ? -2 : 0; +if( check_user_perm( 'users', 'edit' ) ) { // We have permission to modify: $td_group_name = '$ufgp_name$'; } @@ -135,7 +135,7 @@ function filter_userfields( & $Form ) 'td_colspan' => $group_td_colspan, 'td' => ''.$td_group_name.'', ); -if( $current_User->check_perm( 'users', 'edit', false ) ) +if( check_user_perm( 'users', 'edit', false ) ) { // We have permission to modify: $Results->grp_cols[] = array( 'td' => '$ufgp_order$', @@ -144,10 +144,10 @@ function filter_userfields( & $Form ) function grp_actions( & $row ) { - global $usedgroups, $current_User; + global $usedgroups; $r = ''; - if( $current_User->check_perm( 'users', 'edit', false ) ) + if( check_user_perm( 'users', 'edit', false ) ) { $r = action_icon( T_('Edit this group...'), 'edit', regenerate_url( 'ctrl,action', 'ctrl=userfieldsgroups&action=edit&ufgp_ID='.$row->ufgp_ID ) ) .action_icon( T_('Duplicate this group...'), 'copy', regenerate_url( 'ctrl,action', 'ctrl=userfieldsgroups&action=new&ufgp_ID='.$row->ufgp_ID ) ); @@ -201,7 +201,7 @@ function grp_actions( & $row ) 'td_class' => 'center', ); -if( $current_User->check_perm( 'users', 'edit' ) ) +if( check_user_perm( 'users', 'edit' ) ) { // We have permission to modify: function order_actions( & $row ) { diff --git a/inc/users/views/_usertags.view.php b/inc/users/views/_usertags.view.php index 73dbe29a51f..47cfc20b04f 100644 --- a/inc/users/views/_usertags.view.php +++ b/inc/users/views/_usertags.view.php @@ -14,7 +14,7 @@ */ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); -global $current_User, $admin_url; +global $admin_url; $SQL = new SQL(); $SQL->SELECT( 'utag_ID, utag_name, COUNT( ut.uutg_user_ID ) AS tag_count' ); @@ -82,9 +82,9 @@ function filter_tags( & $Form ) function tag_td_name( $utag_ID, $utag_name ) { - global $current_User, $admin_url; + global $admin_url; - if( $current_User->check_perm( 'options', 'edit' ) ) + if( check_user_perm( 'options', 'edit' ) ) { // Display tag name as link to edit form only if current user has a perm: $utag_name = '' @@ -115,7 +115,7 @@ function tag_td_count( $utag_name, $utag_count ) ); -if( $current_User->check_perm( 'options', 'edit' ) ) +if( check_user_perm( 'options', 'edit' ) ) { function tag_td_actions( $utag_ID ) { @@ -130,7 +130,7 @@ function tag_td_actions( $utag_ID ) 'td' => '%tag_td_actions( #utag_ID# )%', ); - if( $current_User->check_perm( 'options', 'edit' ) ) + if( check_user_perm( 'options', 'edit' ) ) { // Allow to clean up tags only if current user has a permission to edit tags: $Results->global_icon( T_('Cleanup orphans'), 'cleanup', regenerate_url( 'action', 'action=cleanup&return_to='.urlencode( regenerate_url( 'action', '', '', '&' ) ) ).'&'.url_crumb( 'usertag' ), T_('Cleanup orphans'), 3, 4 ); } diff --git a/inc/widgets/_widgets.funcs.php b/inc/widgets/_widgets.funcs.php index 680aa404ec0..a709a4a106e 100644 --- a/inc/widgets/_widgets.funcs.php +++ b/inc/widgets/_widgets.funcs.php @@ -22,33 +22,44 @@ /** * Get config array of default widgets for install, upgrade and new collections * - * @param string Collection kind: 'minisite', 'main', 'std', 'photo', 'forum', 'manual', 'group' - * @param integer Collection ID - * @param boolean Should be true only when it's called after initial install - * @return array + * @param string Collection type: 'std', 'main', 'photo', 'group', 'forum', 'manual' + * @param array Context + * @return array Array of default widgets: + * - Key - Container code, + * - Value - array of widget arrays OR SPECIAL VALUES: + * - 'coll_type': Include this container only for collection types separated by comma, first char "-" means to exclude, + * - 'skin_type': Include this container only for skin types separated by comma, first char "-" means to exclude, + * - 'type': Container type, empty - main container, other values: 'sub', 'page', 'shared', 'shared-sub', + * - 'name': Container name, + * - 'order': Container order, + * - widget data array(): + * - 0: Widget order (*mandatory field*), + * - 1: Upgrade block number (*mandatory field*) - Use number of upgrade block(@see $new_db_version in /conf/_application.php) where this widget can be started to install, + * - 2: Widget code (*mandatory field*), + * - 'params' - Widget params(array or serialized string), + * - 'type' - Widget type(default = 'core', another value - 'plugin'), + * - 'enabled' - Boolean value; default is TRUE; FALSE to install the widget as disabled, + * - 'coll_type': Include this widget only for collection types separated by comma, first char "-" means to exclude, + * - 'skin_type': Include this widget only for skin types separated by comma, first char "-" means to exclude, + * - 'install' - Boolean value; default is TRUE; FALSE to skip this widget on install. */ -function get_default_widgets( $kind = '', $blog_id = NULL, $initial_install = false ) +function get_default_widgets( $coll_type = '', $context = array() ) { - global $DB, $install_test_features, $installed_collection_info_pages; - // Handle all blog IDs which can go from function create_demo_contents() - global $blog_minisite_ID, $blog_home_ID, $blog_a_ID, $blog_b_ID, $blog_photoblog_ID, $blog_forums_ID, $blog_manual_ID, $events_blog_ID; - global $demo_poll_ID; - $blog_minisite_ID = intval( $blog_minisite_ID ); - $blog_home_ID = intval( $blog_home_ID ); - $blog_a_ID = intval( $blog_a_ID ); - $blog_b_ID = intval( $blog_b_ID ); - $blog_photoblog_ID = intval( $blog_photoblog_ID ); - $blog_forums_ID = intval( $blog_forums_ID ); - $blog_manual_ID = intval( $blog_manual_ID ); - $events_blog_ID = intval( $events_blog_ID ); - $demo_poll_ID = intval( $demo_poll_ID ); - - // Init insert widget query and default params - $default_blog_param = 's:7:"blog_ID";s:0:"";'; - if( $initial_install && ! empty( $blog_photoblog_ID ) ) - { // In the case of initial install, we grab photos out of the photoblog (Blog #4) - $default_blog_param = 's:7:"blog_ID";s:1:"'.intval( $blog_photoblog_ID ).'";'; - } + global $DB, $installed_collection_info_pages; + + $context = array_merge( array( + 'current_coll_ID' => NULL, + 'coll_home_ID' => NULL, + 'coll_blog_a_ID' => NULL, + 'coll_photoblog_ID' => NULL, + 'poll_ID' => NULL, + 'init_as_home' => false, + 'init_as_blog_a' => false, + 'init_as_blog_b' => false, + 'init_as_forums' => false, + 'init_as_events' => false, + 'install_test_features' => false, + ), $context ); $default_widgets = array(); @@ -63,9 +74,9 @@ function get_default_widgets( $kind = '', $blog_id = NULL, $initial_install = fa 'coll_type' => '-main', // Don't add widgets to Menu container for Main collections array( 5, 15000, 'basic_menu_link', 'coll_type' => '-minisite', 'params' => array( 'link_type' => 'home' ) ), array( 7, 15000, 'mustread_menu_link', 'is_pro' => true, 'coll_type' => '-main,minisite' ), - array( 8, 15000, 'flag_menu_link', 'coll_type' => 'forum,group', 'params' => array( 'link_type' => 'latestcomments', 'link_text' => T_('Flagged topics') ) ), - array( 8, 15000, 'flag_menu_link', 'coll_type' => 'manual', 'params' => array( 'link_type' => 'latestcomments', 'link_text' => T_('Flagged pages') ) ), - array( 10, 15000, 'basic_menu_link', 'coll_ID' => $blog_b_ID, 'params' => array( 'link_type' => 'recentposts', 'link_text' => T_('News') ) ), + array( 8, 15000, 'basic_menu_link', 'coll_type' => 'forum,group', 'params' => array( 'link_type' => 'flagged', 'link_text' => T_('Flagged topics') ) ), + array( 8, 15000, 'basic_menu_link', 'coll_type' => 'manual', 'params' => array( 'link_type' => 'flagged', 'link_text' => T_('Flagged pages') ) ), + array( 10, 15000, 'basic_menu_link', 'install' => $context['init_as_blog_b'], 'params' => array( 'link_type' => 'recentposts', 'link_text' => T_('News') ) ), array( 13, 15000, 'basic_menu_link', 'coll_type' => 'forum', 'params' => array( 'link_type' => 'recentposts', 'link_text' => T_('Latest topics') ) ), array( 15, 15000, 'basic_menu_link', 'coll_type' => 'forum', 'params' => array( 'link_type' => 'latestcomments', 'link_text' => T_('Latest replies') ) ), array( 13, 15000, 'basic_menu_link', 'coll_type' => 'manual', 'params' => array( 'link_type' => 'recentposts', 'link_text' => T_('Latest pages') ) ), @@ -78,14 +89,15 @@ function get_default_widgets( $kind = '', $blog_id = NULL, $initial_install = fa array( 33, 15000, 'basic_menu_link', 'coll_type' => 'std', 'params' => array( 'link_type' => 'catdir' ) ), array( 35, 15000, 'basic_menu_link', 'coll_type' => 'std', 'params' => array( 'link_type' => 'arcdir' ) ), array( 37, 15000, 'basic_menu_link', 'coll_type' => 'std', 'params' => array( 'link_type' => 'latestcomments' ) ), - array( 50, 15000, 'msg_menu_link', 'params' => array( 'link_type' => 'messages' ), 'enabled' => 0 ), - array( 60, 15000, 'basic_menu_link', 'params' => array( 'link_type' => 'ownercontact', 'show_badge' => 0 ), 'enabled' => ( $kind == 'minisite' ) ), + array( 50, 15000, 'basic_menu_link', 'params' => array( 'link_type' => 'messages' ), 'enabled' => 0 ), + array( 60, 15000, 'basic_menu_link', 'params' => array( 'link_type' => 'ownercontact', 'show_badge' => 0 ), 'enabled' => ( $coll_type == 'minisite' ) ), array( 70, 15000, 'basic_menu_link', 'params' => array( 'link_type' => 'login' ), 'enabled' => 0 ), array( 80, 15000, 'basic_menu_link', 'coll_type' => 'forum', 'params' => array( 'link_type' => 'register' ) ), ); /* Item List */ $default_widgets['item_list'] = array( + array( 5, 16150, 'request_title' ), array( 10, 15190, 'coll_item_list_pages' ), ); @@ -118,9 +130,9 @@ function get_default_widgets( $kind = '', $blog_id = NULL, $initial_install = fa array( 15, 15000, 'item_attachments', 'coll_type' => '-manual' ), array( 17, 15000, 'item_link', 'coll_type' => '-manual' ), array( 18, 15000, 'item_workflow', 'coll_type' => 'photo' ), - array( 20, 15000, 'item_tags', 'coll_type' => '-forum,group,manual', 'coll_ID' => '-'.$blog_a_ID.','.$events_blog_ID ), - array( 25, 15000, 'item_about_author', 'coll_ID' => $blog_b_ID ), - array( 40, 15000, 'item_small_print', 'coll_ID' => $blog_a_ID, 'params' => array( 'template' => 'item_details_smallprint_standard' ) ), + array( 20, 15000, 'item_tags', 'coll_type' => '-forum,group,manual', 'install' => ! $context['init_as_blog_a'] && ! $context['init_as_events'] ), + array( 25, 15000, 'item_about_author', 'install' => $context['init_as_blog_b'] ), + array( 40, 15000, 'item_small_print', 'install' => $context['init_as_blog_a'], 'params' => array( 'template' => 'item_details_smallprint_standard' ) ), array( 40, 15000, 'item_small_print', 'coll_type' => 'manual', 'params' => array( 'template' => 'item_details_revisions' ) ), array( 50, 15000, 'item_seen_by', 'coll_type' => '-forum,group,manual' ), array( 60, 15000, 'item_vote', 'coll_type' => '-forum,group,manual' ), @@ -135,7 +147,9 @@ function get_default_widgets( $kind = '', $blog_id = NULL, $initial_install = fa ); /* Comment List */ - $default_widgets['comment_list'] = array(); + $default_widgets['comment_list'] = array( + array( 5, 16130, 'request_title' ), + ); /* Comment Area */ $default_widgets['comment_area'] = array( @@ -150,6 +164,7 @@ function get_default_widgets( $kind = '', $blog_id = NULL, $initial_install = fa /* Sidebar Single */ $default_widgets['sidebar_single'] = array( array( 1, 15000, 'item_workflow', 'coll_type' => 'forum,group,manual' ), + array( 3, 16110, 'item_checklist_lines', 'coll_type' => 'group' ), array( 5, 15000, 'coll_related_post_list', 'coll_type' => 'forum' ), array( 10, 15000, 'item_vote', 'coll_type' => 'manual' ), array( 20, 15000, 'item_tags', 'coll_type' => 'manual' ), @@ -175,7 +190,7 @@ function get_default_widgets( $kind = '', $blog_id = NULL, $initial_install = fa ); /* Sidebar */ - if( $kind == 'manual' ) + if( $coll_type == 'manual' ) { $default_widgets['sidebar'] = array( 'coll_type' => 'manual', @@ -186,28 +201,28 @@ function get_default_widgets( $kind = '', $blog_id = NULL, $initial_install = fa else { // Special checking to don't install several Sidebar widgets below for collection 'Forums': - $install_not_forum = ( ( ! $initial_install || $blog_id != $blog_forums_ID ) && $kind != 'forum' ); - if( $blog_id == $blog_home_ID ) + $install_not_forum = ( ! $context['init_as_forums'] && $coll_type != 'forum' ); + if( $context['init_as_home'] ) { // Advertisements, Install only for collection #1 home collection: $advertisement_type_ID = $DB->get_var( 'SELECT ityp_ID FROM T_items__type WHERE ityp_name = "Advertisement"' ); } - if( ! empty( $blog_home_ID ) && ( $blog_id == $blog_a_ID || $blog_id == $blog_b_ID ) ) + if( ! empty( $context['coll_home_ID'] ) && ( $context['init_as_blog_a'] || $context['init_as_blog_b'] ) ) { $sidebar_type_ID = $DB->get_var( 'SELECT ityp_ID FROM T_items__type WHERE ityp_name = "Sidebar link"' ); } $default_widgets['sidebar'] = array( - array( 5, 15000, 'coll_current_filters', 'coll_type' => '-forum', 'install' => $install_test_features ), - array( 10, 15000, 'user_login', 'install' => $install_test_features ), - array( 15, 15000, 'user_greetings', 'install' => $install_test_features ), + array( 5, 15000, 'coll_current_filters', 'coll_type' => '-forum', 'install' => $context['install_test_features'] ), + array( 10, 15000, 'user_login', 'install' => $context['install_test_features'] ), + array( 15, 15000, 'user_greetings', 'install' => $context['install_test_features'] ), array( 20, 15000, 'user_profile_pics', 'install' => $install_not_forum ), - array( 30, 15000, 'evo_Calr', 'type' => 'plugin', 'install' => ( $install_not_forum && $blog_id > $blog_a_ID ) ), + array( 30, 15000, 'evo_Calr', 'type' => 'plugin', 'install' => ( $install_not_forum && $context['current_coll_ID'] > $context['coll_blog_a_ID'] ) ), array( 40, 15000, 'coll_longdesc', 'install' => $install_not_forum, 'params' => array( 'title' => '$title$' ) ), array( 50, 15000, 'coll_search_form', 'install' => $install_not_forum, 'params' => array( 'template' => 'search_form_simple' ) ), array( 60, 15000, 'coll_category_list', 'install' => $install_not_forum ), - array( 70, 15000, 'coll_item_list', 'coll_ID' => $blog_home_ID, 'install' => $install_not_forum, 'params' => array( + array( 70, 15000, 'coll_item_list', 'install' => $install_not_forum && $context['init_as_home'], 'params' => array( 'title' => 'Advertisement (Demo)', 'item_type' => empty( $advertisement_type_ID ) ? '#' : $advertisement_type_ID, - 'blog_ID' => $blog_id, + 'blog_ID' => $context['current_coll_ID'], 'order_by' => 'RAND', 'limit' => 1, 'disp_title' => false, @@ -216,9 +231,19 @@ function get_default_widgets( $kind = '', $blog_id = NULL, $initial_install = fa 'item_pic_link_type' => 'linkto_url', 'thumb_size' => 'fit-160x160', ) ), - array( 80, 15000, 'coll_media_index', 'coll_ID' => '-'.$blog_b_ID, 'install' => $install_not_forum, 'params' => 'a:11:{s:5:"title";s:12:"Random photo";s:10:"thumb_size";s:11:"fit-160x120";s:12:"thumb_layout";s:4:"grid";s:12:"grid_nb_cols";s:1:"1";s:5:"limit";s:1:"1";s:8:"order_by";s:4:"RAND";s:9:"order_dir";s:3:"ASC";'.$default_blog_param.'s:11:"widget_name";s:12:"Random photo";s:16:"widget_css_class";s:0:"";s:9:"widget_ID";s:0:"";}' ), - array( 90, 15000, 'coll_item_list', 'coll_ID' => $blog_a_ID.','.$blog_b_ID, 'install' => $install_not_forum, 'params' => array( - 'blog_ID' => $blog_home_ID, + array( 80, 15000, 'coll_media_index', 'install' => ( $install_not_forum && ! $context['init_as_blog_b'] ), 'params' => array( + 'title' => 'Random photo', + 'thumb_size' => 'fit-160x120', + 'thumb_layout' => 'grid', + 'grid_nb_cols' => 1, + 'limit' => 1, + 'order_by' => 'RAND', + 'order_dir' => 'ASC', + // In the case of initial install, we grab photos out of the photoblog: + 'blog_ID' => ( empty( $context['coll_photoblog_ID'] ) ? '' : intval( $context['coll_photoblog_ID'] ) ), + ) ), + array( 90, 15000, 'coll_item_list', 'install' => ( $install_not_forum && ( $context['init_as_blog_a'] || $context['init_as_blog_b'] ) ), 'params' => array( + 'blog_ID' => $context['coll_home_ID'], 'item_type' => empty( $sidebar_type_ID ) ? '#' : $sidebar_type_ID, 'title' => 'Linkblog', 'item_group_by' => 'chapter', @@ -240,15 +265,28 @@ function get_default_widgets( $kind = '', $blog_id = NULL, $initial_install = fa $default_widgets['sidebar_2'] = array( 'coll_type' => '-forum', array( 1, 15000, 'coll_post_list' ), - array( 5, 15000, 'coll_item_list', 'coll_ID' => $blog_b_ID, 'params' => array( + array( 5, 15000, 'coll_item_list', 'install' => $context['init_as_blog_b'], 'params' => array( 'title' => 'Sidebar links', 'order_by' => 'RAND', 'item_title_link_type' => 'auto', 'item_type_usage' => 'special', ) ), array( 10, 15000, 'coll_comment_list' ), - array( 15, 15000, 'coll_media_index', 'params' => 'a:11:{s:5:"title";s:13:"Recent photos";s:10:"thumb_size";s:10:"crop-80x80";s:12:"thumb_layout";s:4:"flow";s:12:"grid_nb_cols";s:1:"3";s:5:"limit";s:1:"9";s:8:"order_by";s:9:"datestart";s:9:"order_dir";s:4:"DESC";'.$default_blog_param.'s:11:"widget_name";s:11:"Photo index";s:16:"widget_css_class";s:0:"";s:9:"widget_ID";s:0:"";}' ), - array( 20, 15000, 'free_html', 'params' => 'a:5:{s:5:"title";s:9:"Sidebar 2";s:7:"content";s:166:"This is the "Sidebar 2" container. You can place any widget you like in here. In the evo toolbar at the top of this page, select "Collection", then "Widgets…".";s:11:"widget_name";s:9:"Free HTML";s:16:"widget_css_class";s:0:"";s:9:"widget_ID";s:0:"";}' ), + array( 15, 15000, 'coll_media_index', 'params' => array( + 'title' => 'Recent photos', + 'thumb_size' => 'crop-80x80', + 'thumb_layout' => 'flow', + 'grid_nb_cols' => 3, + 'limit' => 9, + 'order_by' => 'datestart', + 'order_dir' => 'DESC', + // In the case of initial install, we grab photos out of the photoblog: + 'blog_ID' => ( empty( $context['coll_photoblog_ID'] ) ? '' : intval( $context['coll_photoblog_ID'] ) ), + ) ), + array( 20, 15000, 'free_html', 'params' => array( + 'title' => 'Sidebar 2', + 'content' => 'This is the "Sidebar 2" container. You can place any widget you like in here. In the evo toolbar at the top of this page, select "Customize", then "Blog Widgets".', + ) ), ); /* Front Page Main Area */ @@ -261,7 +299,7 @@ function get_default_widgets( $kind = '', $blog_id = NULL, $initial_install = fa .T_('You can think of collections as "sections" of your site. Different collections/sections may have different purposes: blog, photo gallery, forums, manual, etc. You can add or remove collections at will through the back-office. You can even remove this "Home" collection if you don\'t need it.')."\n\n" .T_('Feel free to experiment! If you delete all collections, the Quick start wizard will come back and you will be able to start with a completely new arrangement of collections.'), ) ), - array( 10, 15000, 'coll_featured_intro', 'coll_type' => '-main,minisite', 'params' => ( $kind == 'main' ? array( + array( 10, 15000, 'coll_featured_intro', 'coll_type' => '-main,minisite', 'params' => ( $coll_type == 'main' ? array( // Hide a title of the front intro post: 'disp_title' => 0, ) : NULL ) ), @@ -275,7 +313,7 @@ function get_default_widgets( $kind = '', $blog_id = NULL, $initial_install = fa 'link4' => 'github', 'link4_href' => 'https://github.com/b2evolution/b2evolution', ) ), - array( 20, 15000, 'coll_featured_posts', 'coll_type' => '-minisite', 'params' => ( $kind == 'main' ? array( + array( 20, 15000, 'coll_featured_posts', 'coll_type' => '-minisite', 'params' => ( $coll_type == 'main' ? array( 'blog_ID' => '*', // Display Items from all Collections 'limit' => 5, 'layout' => 'list', @@ -287,7 +325,7 @@ function get_default_widgets( $kind = '', $blog_id = NULL, $initial_install = fa 'featured' => 'other', ) ), // Install widget "Poll" only for Blog B on install: - array( 40, 15000, 'poll', 'coll_ID' => $blog_b_ID, 'params' => array( 'poll_ID' => $demo_poll_ID ) ), + array( 40, 15000, 'poll', 'install' => $context['init_as_blog_b'], 'params' => array( 'poll_ID' => $context['poll_ID'] ) ), array( 45, 15000, 'content_hierarchy', 'coll_type' => 'manual' ), array( 50, 15000, 'subcontainer_row', 'coll_type' => '-main', 'params' => array( 'column1_container' => 'coll:front_page_column_a', @@ -399,12 +437,14 @@ function get_default_widgets( $kind = '', $blog_id = NULL, $initial_install = fa /* Mobile Footer */ $default_widgets['mobile_footer'] = array( + 'skin_type' => 'mobile', array( 10, 15000, 'coll_longdesc' ), array( 20, 15000, 'mobile_skin_switcher' ), ); /* Mobile Navigation Menu */ $default_widgets['mobile_navigation_menu'] = array( + 'skin_type' => 'mobile', array( 10, 15000, 'coll_page_list' ), array( 20, 15000, 'basic_menu_link', 'params' => array( 'link_type' => 'ownercontact' ) ), array( 30, 15000, 'basic_menu_link', 'params' => array( 'link_type' => 'home' ) ), @@ -413,9 +453,10 @@ function get_default_widgets( $kind = '', $blog_id = NULL, $initial_install = fa /* Mobile Tools Menu */ $default_widgets['mobile_tools_menu'] = array( + 'skin_type' => 'mobile', array( 10, 15000, 'basic_menu_link', 'params' => array( 'link_type' => 'login' ) ), - array( 20, 15000, 'msg_menu_link', 'params' => array( 'link_type' => 'messages' ) ), - array( 30, 15000, 'msg_menu_link', 'params' => array( 'link_type' => 'contacts', 'show_badge' => 0 ) ), + array( 20, 15000, 'basic_menu_link', 'params' => array( 'link_type' => 'messages' ) ), + array( 30, 15000, 'basic_menu_link', 'params' => array( 'link_type' => 'contacts', 'show_badge' => 0 ) ), array( 50, 15000, 'basic_menu_link', 'params' => array( 'link_type' => 'logout' ) ), ); @@ -562,8 +603,34 @@ function get_default_widgets( $kind = '', $blog_id = NULL, $initial_install = fa /* Search Area */ $default_widgets['search_area'] = array( + array( 5, 16140, 'request_title' ), array( 10, 15960, 'coll_search_form', 'params' => array( 'template' => 'search_form_full', + 'widget_css_class' => 'well', + ) ), + ); + + /* Site Map */ + $default_widgets['sitemap'] = array( + array( 10, 16090, 'embed_menu', 'params' => array( + 'title' => T_('Common links'), + 'menu_ID' => get_default_site_menu_ID( 'Site Map - Common links' ), + 'display_mode' => 'list', + ) ), + array( 20, 16090, 'coll_page_list', 'params' => array( + 'title' => T_('Pages'), + 'order_by' => 'title', + 'order_dir' => 'ASC', + 'limit' => '', + ) ), + array( 30, 16090, 'coll_category_list', 'params' => array( + 'title' => T_('Categories'), + ) ), + array( 40, 16090, 'coll_post_list', 'params' => array( + 'title' => T_('Posts'), + 'order_by' => 'title', + 'order_dir' => 'ASC', + 'limit' => '', ) ), ); @@ -628,7 +695,8 @@ function get_default_widgets( $kind = '', $blog_id = NULL, $initial_install = fa 'widget_css_class' => 'visible-xs', 'widget_link_class'=> 'bg-white', ) ), - array( $tmp_widget_order + 40, 15260, 'msg_menu_link', 'params' => array( + array( $tmp_widget_order + 40, 15260, 'basic_menu_link', 'params' => array( + 'link_type' => 'messages', 'widget_css_class' => 'visible-xs', ) ), array( $tmp_widget_order + 50, 15260, 'basic_menu_link', 'params' => array( @@ -676,10 +744,12 @@ function get_default_widgets( $kind = '', $blog_id = NULL, $initial_install = fa 'link_type' => 'register', 'widget_link_class' => 'hidden-xs bg-white', ) ), - array( 30, 15260, 'profile_menu_link', 'params' => array( + array( 30, 15260, 'basic_menu_link', 'params' => array( + 'link_type' => 'myprofile', 'profile_picture_size' => 'crop-top-32x32', ) ), - array( 40, 15260, 'msg_menu_link', 'params' => array( + array( 40, 15260, 'basic_menu_link', 'params' => array( + 'link_type' => 'messages', 'widget_link_class' => 'hidden-xs', ) ), array( 50, 15260, 'basic_menu_link', 'params' => array( @@ -706,6 +776,7 @@ function get_default_widgets( $kind = '', $blog_id = NULL, $initial_install = fa /* Widget Page Section 1 */ $default_widgets['widget_page_section_1'] = array( + 'coll_type' => 'main', 'type' => 'page', 'name' => NT_('Widget Page Section 1'), 'order' => 10, @@ -721,6 +792,7 @@ function get_default_widgets( $kind = '', $blog_id = NULL, $initial_install = fa /* Widget Page Section 2 */ $default_widgets['widget_page_section_2'] = array( + 'coll_type' => 'main', 'type' => 'page', 'name' => NT_('Widget Page Section 2'), 'order' => 20, @@ -730,6 +802,7 @@ function get_default_widgets( $kind = '', $blog_id = NULL, $initial_install = fa /* Widget Page Section 3 */ $default_widgets['widget_page_section_3'] = array( + 'coll_type' => 'main', 'type' => 'page', 'name' => NT_('Widget Page Section 3'), 'order' => 30, @@ -747,13 +820,12 @@ function get_default_widgets( $kind = '', $blog_id = NULL, $initial_install = fa * * @param string Container code * @param string Collection kind - * @param integer Collection ID - * @param boolean Should be true only when it's called after initial install + * @param array Context * @return array|boolean FALSE if no widgets for a requested container */ -function get_default_widgets_by_container( $container_code, $kind = '', $blog_id = NULL, $initial_install = false ) +function get_default_widgets_by_container( $container_code, $coll_type = '', $context = array() ) { - $default_widgets = get_default_widgets( $kind, $blog_id, $initial_install ); + $default_widgets = get_default_widgets( $coll_type, $context ); return isset( $default_widgets[ $container_code ] ) ? $default_widgets[ $container_code ] : false; } @@ -1076,154 +1148,6 @@ function is_installed_widget( $widget_code, $container_code, $coll_ID = NULL ) in_array( $widget_code, $evo_installed_widgets_by_container_collection[ $container_code ][ $coll_ID ] ) ); } -/** - * Insert the basic widgets for a collection - * - * @param integer should never be 0 - * @param string Skin type: 'normal', 'mobile', 'tablet', 'alt' - * @param boolean should be true only when it's called after initial install - * fp> TODO: $initial_install is used to know if we want to trust globals like $blog_photoblog_ID and $blog_forums_ID. We don't want that. - * We should pass a $context array with values like 'photo_source_coll_ID' => 4. - * Also, checking $blog_forums_ID is unnecessary complexity. We can check the collection kind == forum - * @param string Kind of blog ( 'std', 'photo', 'group', 'forum' ) - */ -function insert_basic_widgets( $blog_id, $skin_type, $initial_install = false, $kind = '' ) -{ - global $DB, $install_test_features; - - // Handle all blog IDs which can go from function create_demo_contents() - global $blog_minisite_ID, $blog_home_ID, $blog_a_ID, $blog_b_ID, $blog_photoblog_ID, $blog_forums_ID, $blog_manual_ID, $events_blog_ID; - $blog_minisite_ID = intval( $blog_minisite_ID ); - $blog_home_ID = intval( $blog_home_ID ); - $blog_a_ID = intval( $blog_a_ID ); - $blog_b_ID = intval( $blog_b_ID ); - $blog_photoblog_ID = intval( $blog_photoblog_ID ); - $blog_forums_ID = intval( $blog_forums_ID ); - $blog_manual_ID = intval( $blog_manual_ID ); - $events_blog_ID = intval( $events_blog_ID ); - - $BlogCache = & get_BlogCache(); - if( ! ( $Blog = & $BlogCache->get_by_ID( $blog_id, false, false ) ) ) - { // Wrong requested collection: - return; - } - - // Get all containers declared in the given collection skin type: - $blog_containers = $Blog->get_skin_containers( $skin_type ); - - if( empty( $blog_containers ) ) - { // No containers for given skin: - return; - } - - // Get config of default widgets: - $default_widgets = get_default_widgets( $kind, $blog_id, $initial_install ); - - // Install additional sub-containers and page containers from default config, - // which are not declared as main containers but should be installed too: - foreach( $default_widgets as $wico_code => $container_widgets ) - { - if( isset( $container_widgets['type'] ) && - ( $container_widgets['type'] == 'sub' || $container_widgets['type'] == 'page' ) ) - { // If it is a sub-container or page container: - $blog_containers[ $wico_code ] = array( - isset( $container_widgets['name'] ) ? $container_widgets['name'] : $wico_code, - isset( $container_widgets['order'] ) ? $container_widgets['order'] : 1, - ( $container_widgets['type'] == 'sub' ? 0 : 1 ), // Main or Sub-container - isset( $container_widgets['item_ID'] ) ? $container_widgets['item_ID'] : NULL, - ); - } - } - - // Create rows to insert for all collection containers: - $widget_containers_sql_rows = array(); - foreach( $blog_containers as $wico_code => $wico_data ) - { - $widget_containers_sql_rows[] = '( '.$DB->quote( $wico_code ).', ' - .$DB->quote( $skin_type ).', ' - .$DB->quote( $wico_data[0] ).', ' - .$blog_id.', ' - .$DB->quote( $wico_data[1] ).', ' - .( isset( $wico_data[2] ) ? intval( $wico_data[2] ) : '1' ).', ' - .( isset( $wico_data[3] ) ? intval( $wico_data[3] ) : 'NULL' ).' )'; - } - - // Insert widget containers records by one SQL query - $DB->query( 'INSERT INTO T_widget__container ( wico_code, wico_skin_type, wico_name, wico_coll_ID, wico_order, wico_main, wico_item_ID ) VALUES' - .implode( ', ', $widget_containers_sql_rows ) ); - - $insert_id = $DB->insert_id; - foreach( $blog_containers as $wico_code => $wico_data ) - { - $blog_containers[ $wico_code ]['wico_ID'] = $insert_id; - $insert_id++; - } - - $basic_widgets_insert_sql_rows = array(); - foreach( $default_widgets as $wico_code => $container_widgets ) - { - if( ! isset( $blog_containers[ $wico_code ] ) ) - { // Skip container which is not supported by current colelction's skin: - continue; - } - - if( ! empty( $container_widgets['type'] ) && - ! in_array( $container_widgets['type'], array( 'main', 'sub', 'page' ) ) ) - { // Skip not collection container: - continue; - } - - if( isset( $container_widgets['coll_type'] ) && - ! is_allowed_option( $kind, $container_widgets['coll_type'] ) ) - { // Skip container because it should not be installed for the given collection kind: - continue; - } - - $wico_id = $blog_containers[ $wico_code ]['wico_ID']; - - foreach( $container_widgets as $key => $widget ) - { - if( ! is_number( $key ) ) - { // Skip the config data which is used as additional info for container like 'type', 'name', 'order', 'item_ID', 'coll_type': - continue; - } - - if( isset( $widget['install'] ) && ! $widget['install'] ) - { // Skip widget because it should not be installed by condition from config: - continue; - } - - if( isset( $widget['coll_type'] ) && ! is_allowed_option( $kind, $widget['coll_type'] ) ) - { // Skip widget because it should not be installed for the given collection kind: - continue; - } - - if( isset( $widget['is_pro'] ) && $widget['is_pro'] !== is_pro() ) - { // Skip widget because it should not be installed for the current version: - continue; - } - - if( isset( $widget['coll_ID'] ) && ! is_allowed_option( $blog_id, $widget['coll_ID'] ) ) - { // Skip widget because it should not be installed for the given collection ID: - continue; - } - - // Initialize a widget row to insert into DB below by single query: - $widget_type = isset( $widget['type'] ) ? $widget['type'] : 'core'; - $widget_params = isset( $widget['params'] ) ? ( is_array( $widget['params'] ) ? serialize( $widget['params'] ) : $widget['params'] ) : NULL; - $widget_enabled = isset( $widget['enabled'] ) ? intval( $widget['enabled'] ) : 1; - $basic_widgets_insert_sql_rows[] = '( '.$wico_id.', '.$widget[0].', '.$widget_enabled.', '.$DB->quote( $widget_type ).', '.$DB->quote( $widget[2] ).', '.$DB->quote( $widget_params ).' )'; - } - } - - // Check if there are widgets to create - if( ! empty( $basic_widgets_insert_sql_rows ) ) - { // Insert the widget records by single SQL query - $DB->query( 'INSERT INTO T_widget__widget( wi_wico_ID, wi_order, wi_enabled, wi_type, wi_code, wi_params ) ' - .'VALUES '.implode( ', ', $basic_widgets_insert_sql_rows ) ); - } -} - /** * Get WidgetContainer object from the widget list view widget container fieldset id @@ -1311,6 +1235,12 @@ function insert_shared_widgets( $skin_type ) continue; } + if( isset( $container_widgets['skin_type'] ) && + ! is_allowed_option( $skin_type, $container_widgets['skin_type'] ) ) + { // Skip container because it should not be installed for the given skin type: + continue; + } + if( isset( $container_widgets['name'] ) ) { // Handle special array item with container data: if( ! isset( $shared_containers[ $wico_code ] ) ) @@ -1349,6 +1279,11 @@ function insert_shared_widgets( $skin_type ) continue; } + if( isset( $widget['skin_type'] ) && ! is_allowed_option( $skin_type, $widget['skin_type'] ) ) + { // Skip widget because it should not be installed for the given skin type: + continue; + } + if( isset( $shared_widgets[ $wico_id ][ $widget[0] ] ) ) { // Skip the widget because a widget was already installed for the container with same order: continue; @@ -1376,7 +1311,7 @@ function insert_shared_widgets( $skin_type ) */ function display_container( $WidgetContainer, $params = array() ) { - global $Collection, $Blog, $DB, $admin_url, $embedded_containers, $mode; + global $Collection, $Blog, $DB, $embedded_containers, $mode; global $Session; $params = array_merge( array( @@ -1397,14 +1332,14 @@ function display_container( $WidgetContainer, $params = array() ) { $widget_container_id = 'wico_ID_'.$WidgetContainer->ID; $add_widget_url = regenerate_url( '', 'action=new&wico_ID='.$WidgetContainer->ID.'&container='.$widget_container_id ); - $destroy_container_url = url_add_param( $admin_url, 'ctrl=widgets&action=destroy_container&wico_ID='.$WidgetContainer->ID.'&'.url_crumb('widget_container') ); + $destroy_container_url = get_admin_url( 'ctrl=widgets&action=destroy_container&wico_ID='.$WidgetContainer->ID.'&'.url_crumb('widget_container') ); } else { $wico_code = $WidgetContainer->get( 'code' ); $widget_container_id = 'wico_code_'.$wico_code; $add_widget_url = regenerate_url( '', 'action=new&wico_code='.$wico_code.'&container='.$widget_container_id ); - $destroy_container_url = url_add_param( $admin_url, 'ctrl=widgets&action=destroy_container&wico_code='.$wico_code.'&'.url_crumb('widget_container') ); + $destroy_container_url = get_admin_url( 'ctrl=widgets&action=destroy_container&wico_code='.$wico_code.'&'.url_crumb('widget_container') ); } if( $mode == 'customizer' ) @@ -1424,14 +1359,14 @@ function display_container( $WidgetContainer, $params = array() ) $Table->title = ''.$widget_container_name.''; if( ! empty( $WidgetContainer->ID ) ) { // Link to edit current widget container: - $Table->global_icon( T_('Edit widget container'), 'edit', $admin_url.'?ctrl=widgets&blog='.$Blog->ID.'&action=edit_container&wico_ID='.$WidgetContainer->ID.'&mode='.$mode, T_('Edit widget container'), 0, 0 ); + $Table->global_icon( T_('Edit widget container'), 'edit', get_admin_url( 'ctrl=widgets&blog='.$Blog->ID.'&action=edit_container&wico_ID='.$WidgetContainer->ID.'&mode='.$mode ), T_('Edit widget container'), 0, 0 ); } } else { // Normal/back-office mode: if( ! empty( $WidgetContainer->ID ) ) { - $widget_container_name = ''.$widget_container_name.''; + $widget_container_name = ''.$widget_container_name.''; if( $WidgetContainer->get_type() == 'page' ) { // Display additional info for Page Container: $ItemCache = & get_ItemCache(); @@ -1455,14 +1390,14 @@ function display_container( $WidgetContainer, $params = array() ) if( get_default_widgets_by_container( $WidgetContainer->get( 'code' ) ) !== false ) { // Action icon to remove all widgets and replace with default widgets of the container from config: $Table->global_icon( T_('Reload container widgets'), 'reload', - $admin_url.'?ctrl=widgets&blog='.$Blog->ID.'&action=reload_container&wico_ID='.$WidgetContainer->ID.'&skin_type='.get_param( 'skin_type' ).'&'.url_crumb( 'widget_container' ), + get_admin_url( 'ctrl=widgets&blog='.$Blog->ID.'&action=reload_container&wico_ID='.$WidgetContainer->ID.'&skin_type='.get_param( 'skin_type' ).'&'.url_crumb( 'widget_container' ) ), '', 0, 0, array( 'onclick' => 'return confirm( \''.TS_('Do you want to reload the default widgets for this container?').'\n'.TS_('THIS CANNOT BE UNDONE!').'\n'.TS_('YOU MAY LOSE SOME CUSTOMIZATIONS!').'\' )' ) ); } $add_widget_link_params = array(); if( $mode == 'customizer' ) { // Set special url to add new widget on customizer mode: - $add_widget_url = $admin_url.'?ctrl=widgets&blog='.$Blog->ID.'&skin_type='.$Blog->get_skin_type().'&action=add_list&container='.urlencode( $WidgetContainer->get( 'name' ) ).'&container_code='.urlencode( $WidgetContainer->get( 'code' ) ).'&mode=customizer'; + $add_widget_url = get_admin_url( 'ctrl=widgets&blog='.$Blog->ID.'&skin_type='.$Blog->get_skin_type().'&action=add_list&container='.urlencode( $WidgetContainer->get( 'name' ) ).'&container_code='.urlencode( $WidgetContainer->get( 'code' ) ).'&mode=customizer' ); } else { // Add id for link to initialize JS code of opening modal window only for not customizer mode, @@ -1598,7 +1533,7 @@ function display_container( $WidgetContainer, $params = array() ) case 'denied': echo action_icon( T_( 'This widget could be cached but the block cache is OFF. Click to enable.' ), 'block_cache_denied', - $admin_url.'?ctrl=coll_settings&tab=advanced&blog='.$Blog->ID.'#fieldset_wrapper_caching', NULL, NULL, NULL, + get_admin_url( 'ctrl=coll_settings&tab=advanced&blog='.$Blog->ID ).'#fieldset_wrapper_caching', NULL, NULL, NULL, array( 'rel' => $widget_cache_status ) ); break; diff --git a/inc/widgets/model/_widget.class.php b/inc/widgets/model/_widget.class.php index 712f11925c3..9f8268beafc 100644 --- a/inc/widgets/model/_widget.class.php +++ b/inc/widgets/model/_widget.class.php @@ -866,7 +866,7 @@ function display( $params ) { // Plugin failed (happens when a plugin has been disabled for example): if( $this->mode == 'designer' ) { // Display red text in customizer widget designer mode in order to make this plugin visible for editing: - echo $this->disp_params['block_start'].''.T_('Inactive / Uninstalled plugin').': "'.$this->code.'"'.$this->disp_params['block_end']; + echo $this->disp_params['block_start'].get_rendering_error( T_('Inactive / Uninstalled plugin').': "'.$this->code.'"', 'span' ).$this->disp_params['block_end']; } return false; } @@ -886,7 +886,7 @@ function display( $params ) */ function display_with_cache( $params, $keys = array() ) { - global $Collection, $Blog, $Timer, $debug, $admin_url, $Session, $current_User; + global $Collection, $Blog, $Timer, $debug, $admin_url, $Session; $this->init_display( $params ); @@ -910,7 +910,7 @@ function display_with_cache( $params, $keys = array() ) $designer_mode_data['data-subcontainer-code'] = $this->get_param( 'container' ); } // Set data to know current user has a permission to edit this widget: - $designer_mode_data['data-can-edit'] = $current_User->check_perm( 'blog_properties', 'edit', false, $Blog->ID ) ? 1 : 0; + $designer_mode_data['data-can-edit'] = check_user_perm( 'blog_properties', 'edit', false, $Blog->ID ) ? 1 : 0; // Don't load a widget content from cache when designer mode is enabled: $force_nocaching = true; // Set designer mode: @@ -930,13 +930,16 @@ function display_with_cache( $params, $keys = array() ) $is_subcontainer = ( $this->get( 'code' ) == 'subcontainer' || $this->get( 'code' ) == 'subcontainer_row' ); echo '
    '; - if( is_logged_in() && $current_User->check_perm( 'blog_properties', 'edit', false, $Blog->ID ) ) + if( check_user_perm( 'blog_properties', 'edit', false, $Blog->ID ) ) { // Display a link to edit this widget only if current user has a permission: echo 'Edit'; } echo 'Widget: '.$this->get_name().' - Cache OFF ?
    '."\n"; } + // Start to collect output buffer in order to can clean up rendering errors when it need below: + ob_start(); + if( ! empty( $designer_mode_data ) ) { // Append designer mode html tag attributes to first not empty widget wrapper/container: $widget_wrappers = array( @@ -986,7 +989,7 @@ function display_with_cache( $params, $keys = array() ) } if( ! $wrapper_is_found ) { // Display error if widget has no wrappers to enable designer mode: - echo ' Widget '.$this->code.' cannot be manipulated because it lacks a wrapper tag. '; + echo ' '.get_rendering_error( 'Widget '.$this->code.' cannot be manipulated because it lacks a wrapper tag.', 'span' ).' '; } } @@ -999,6 +1002,15 @@ function display_with_cache( $params, $keys = array() ) $this->display_debug_message( 'Widget "'.$this->get_name().'" is hidden by code '.$this->code.' from skin template.' ); } + $widget_content = ob_get_clean(); + + if( ! check_user_perm( 'blog_admin', 'edit', false, $Blog->ID ) ) + { // Clean up rendering errors from content if current User is not collection admin: + $widget_content = clear_rendering_errors( $widget_content ); + } + + echo $widget_content; + if( $display_containers ) { // DEBUG: echo "
    \n"; @@ -1022,13 +1034,18 @@ function display_with_cache( $params, $keys = array() ) if( $display_containers ) { // DEBUG: echo '
    '; - if( is_logged_in() && $current_User->check_perm( 'blog_properties', 'edit', false, $Blog->ID ) ) + if( check_user_perm( 'blog_properties', 'edit', false, $Blog->ID ) ) { // Display a link to edit this widget only if current user has a permission: echo 'Edit'; } echo 'Widget: '.$this->get_name().' - FROM cache ?
    '."\n"; } + if( ! check_user_perm( 'blog_admin', 'edit', false, $Blog->ID ) ) + { // Clean up rendering errors from content if current User is not collection admin: + $content = clear_rendering_errors( $content ); + } + echo $content; if( $display_containers ) @@ -1043,7 +1060,7 @@ function display_with_cache( $params, $keys = array() ) if( $display_containers ) { // DEBUG: echo '
    '; - if( is_logged_in() && $current_User->check_perm( 'blog_properties', 'edit', false, $Blog->ID ) ) + if( check_user_perm( 'blog_properties', 'edit', false, $Blog->ID ) ) { // Display a link to edit this widget only if current user has a permission: echo 'Edit'; } @@ -1062,7 +1079,14 @@ function display_with_cache( $params, $keys = array() ) } // Save collected cached data if needed: - $this->BlockCache->end_collect(); + $content = $this->BlockCache->end_collect( false ); + + if( ! check_user_perm( 'blog_admin', 'edit', false, $Blog->ID ) ) + { // Clean up rendering errors from content if current User is not collection admin: + $content = clear_rendering_errors( $content ); + } + + echo $content; if( $display_containers ) { // DEBUG: @@ -1152,7 +1176,10 @@ function disp_title( $title = NULL, $display = true ) if( $this->disp_params['block_display_title'] && !empty( $title ) ) { $r = $this->disp_params['block_title_start']; - $r .= format_to_output( $title ); + if( ! isset( $this->disp_params['hide_header_title'] ) ) + { + $r .= format_to_output( $title ); + } $r .= $this->disp_params['block_title_end']; if( $display ) echo $r; @@ -1553,7 +1580,7 @@ function get_param_item_info( $param_name ) if( ! ( $param_value_is_ID && $param_Item = & $ItemCache->get_by_ID( $param_value, false, false ) ) && ! ( ! $param_value_is_ID && $param_Item = & $ItemCache->get_by_urltitle( $param_value, false, false ) ) ) { // Item is not detected: - return ''.T_('Item is not found.').''; + return get_rendering_error( T_('Item is not found.'), 'span' ); } $item_info = ''; @@ -1618,7 +1645,7 @@ function display_debug_message( $message = NULL ) */ function display_error_message( $message = NULL ) { - global $current_User, $Blog; + global $Blog; if( isset( $this->BlockCache ) ) { // Do NOT cache because this widget has an error which is dispalyed only for collection admin: @@ -1633,9 +1660,9 @@ function display_error_message( $message = NULL ) echo $this->disp_params['block_start']; $this->disp_title(); echo $this->disp_params['block_body_start']; - if( is_logged_in() && $current_User->check_perm( 'blog_admin', 'edit', false, $Blog->ID ) ) + if( check_user_perm( 'blog_admin', 'edit', false, $Blog->ID ) ) { // Display error only for collection admin: - echo ''.$message.''; + display_rendering_error( $message, 'span' ); } echo $this->disp_params['block_body_end']; echo $this->disp_params['block_end']; diff --git a/inc/widgets/model/_widgetcontainer.class.php b/inc/widgets/model/_widgetcontainer.class.php index 38b3948321a..8295f0ae581 100644 --- a/inc/widgets/model/_widgetcontainer.class.php +++ b/inc/widgets/model/_widgetcontainer.class.php @@ -247,6 +247,10 @@ function load_from_Request() { // Display error for unavailable item: param_error( 'wico_item_ID', T_('Item can be used for page container only with Item Type usage "Widget Page"!') ); } + if( $widget_page_Item->get_blog_ID() != $wico_coll_ID ) + { // Display error for Item from another Collection: + param_error( 'wico_item_ID', T_('Item cannot be used from another collection!') ); + } } break; } diff --git a/inc/widgets/views/_widget.form.php b/inc/widgets/views/_widget.form.php index cb2fe20a285..f9a417f120b 100644 --- a/inc/widgets/views/_widget.form.php +++ b/inc/widgets/views/_widget.form.php @@ -130,7 +130,7 @@ if( ! $Blog->get_setting( 'cache_enabled_widgets' ) ) { // Widget/block cache is disabled by blog setting $l_meta['allow_blockcache']['note'] = sprintf( TB_('This widget could be cached but the block cache is OFF. Click here to enable.'), - 'href="'.$admin_url.'?ctrl=coll_settings&tab=advanced&blog='.$Blog->ID.'#fieldset_wrapper_caching"' ); + 'href="'.get_admin_url( 'ctrl=coll_settings&tab=advanced&blog='.$Blog->ID ).'#fieldset_wrapper_caching"' ); $l_meta['disabled'] = 'disabled'; } } @@ -171,7 +171,7 @@ { // Display a button-link to go back (only in customizer mode): $buttons[] = array( 'button', 'button', TB_('Cancel'), 'tag' => 'link', - 'href' => $admin_url.'?ctrl=widgets&blog='.$Blog->ID.'&skin_type='.$Blog->get_skin_type().'&action=customize&container_code='.urlencode( $edited_ComponentWidget->get_container_param( 'code' ) ).'&mode=customizer', + 'href' => get_admin_url( 'ctrl=widgets&blog='.$Blog->ID.'&skin_type='.$Blog->get_skin_type().'&action=customize&container_code='.urlencode( $edited_ComponentWidget->get_container_param( 'code' ) ).'&mode=customizer', '&' ), 'target' => '_self', ); } diff --git a/inc/widgets/views/_widget_list.view.php b/inc/widgets/views/_widget_list.view.php index a1a426f8971..0a8f5d55af1 100644 --- a/inc/widgets/views/_widget_list.view.php +++ b/inc/widgets/views/_widget_list.view.php @@ -13,14 +13,14 @@ */ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); -global $Collection, $Blog, $admin_url; +global $Collection, $Blog; // Get skin ID for the selected widgets type: $skin_ID = $Blog->get( get_param( 'skin_type' ).'_skin_ID', array( 'real_value' => true ) ); if( empty( $skin_ID ) && get_param( 'skin_type' ) != 'normal' ) { // Don't allow to control widgets if same skin is used for mobile/tablet/alt: - echo '
    '.sprintf( T_('If you want control widgets differently for mobile/tablet/alt, select a specific skin here.'), 'href="'.$admin_url.'?ctrl=coll_settings&tab=skin&skinpage=selection&skin_type='.get_param( 'skin_type' ).'&blog='.$Blog->ID.'"' ).'
    '; + echo '
    '.sprintf( T_('If you want control widgets differently for mobile/tablet/alt, select a specific skin here.'), 'href="'.get_admin_url( 'ctrl=coll_settings&tab=skin&skinpage=selection&skin_type='.get_param( 'skin_type' ).'&blog='.$Blog->ID, '&' ).'"' ).'
    '; } else { // Allow to control widgets if different skin is used for mobile/tablet/alt: @@ -29,7 +29,7 @@ $WidgetCache = & get_WidgetCache(); $container_Widget_array = & $WidgetCache->get_by_coll_ID( $Blog->ID, false, get_param( 'skin_type' ) ); - $Form = new Form( $admin_url.'?ctrl=widgets&blog='.$Blog->ID ); + $Form = new Form( get_admin_url( 'ctrl=widgets&blog='.$Blog->ID, '&' ) ); $Form->add_crumb( 'widget' ); @@ -45,7 +45,7 @@ echo '

    '.T_('Skin Containers').'

    '; // Display a button to scan skin for widgets: echo action_icon( T_('Reload container definitions'), 'reload', - $admin_url.'?ctrl=widgets&blog='.$Blog->ID.'&action=reload&skin_type='.get_param( 'skin_type' ).'&'.url_crumb('widget'), T_('Reload container definitions'), 3, 4, array( 'class' => 'action_icon hoverlink btn btn-info pull-right' ) ); + get_admin_url( 'ctrl=widgets&blog='.$Blog->ID.'&action=reload&skin_type='.get_param( 'skin_type' ).'&'.url_crumb('widget') ), T_('Reload container definitions'), 3, 4, array( 'class' => 'action_icon hoverlink btn btn-info pull-right' ) ); echo '
    '; display_containers( get_param( 'skin_type' ), 'main' ); echo '
    '; @@ -56,7 +56,7 @@ echo '

    '.T_('Sub-Containers').'

    '; // Display a button to add new sub-container: echo action_icon( T_('Add Sub-Container'), 'add', - $admin_url.'?ctrl=widgets&blog='.$Blog->ID.'&action=new_container&container_type=sub&skin_type='.get_param( 'skin_type' ), T_('Add Sub-Container').' »', 3, 4, array( 'class' => 'action_icon hoverlink btn btn-default pull-right' ) ); + get_admin_url( 'ctrl=widgets&blog='.$Blog->ID.'&action=new_container&container_type=sub&skin_type='.get_param( 'skin_type' ) ), T_('Add Sub-Container').' »', 3, 4, array( 'class' => 'action_icon hoverlink btn btn-default pull-right' ) ); echo '
    '; display_containers( get_param( 'skin_type' ), 'sub' ); @@ -64,7 +64,7 @@ echo '

    '.T_('Page Containers').'

    '; // Display a button to add new page container: echo action_icon( T_('Add Page container'), 'add', - $admin_url.'?ctrl=widgets&blog='.$Blog->ID.'&action=new_container&container_type=page&skin_type='.get_param( 'skin_type' ), T_('Add Page Container').' »', 3, 4, array( 'class' => 'action_icon hoverlink btn btn-default pull-right' ) ); + get_admin_url( 'ctrl=widgets&blog='.$Blog->ID.'&action=new_container&container_type=page&skin_type='.get_param( 'skin_type' ) ), T_('Add Page Container').' »', 3, 4, array( 'class' => 'action_icon hoverlink btn btn-default pull-right' ) ); echo '
    '; display_containers( get_param( 'skin_type' ), 'page' ); echo '
    '; @@ -74,14 +74,14 @@ echo '

    '.T_('Shared Containers').'

    '; // Display a button to add new shared container: echo action_icon( T_('Add Shared Container'), 'add', - $admin_url.'?ctrl=widgets&blog='.$Blog->ID.'&action=new_container&container_type=shared&skin_type='.get_param( 'skin_type' ), T_('Add Shared Container').' »', 3, 4, array( 'class' => 'action_icon hoverlink btn btn-default pull-right' ) ); + get_admin_url( 'ctrl=widgets&blog='.$Blog->ID.'&action=new_container&container_type=shared&skin_type='.get_param( 'skin_type' ) ), T_('Add Shared Container').' »', 3, 4, array( 'class' => 'action_icon hoverlink btn btn-default pull-right' ) ); echo '
    '; display_containers( get_param( 'skin_type' ), 'shared' ); echo '

    '.T_('Shared Sub-Containers').'

    '; // Display a button to add new shared container: echo action_icon( T_('Add Shared Sub-Container'), 'add', - $admin_url.'?ctrl=widgets&blog='.$Blog->ID.'&action=new_container&container_type=shared-sub&skin_type='.get_param( 'skin_type' ), T_('Add Shared Sub-Container').' »', 3, 4, array( 'class' => 'action_icon hoverlink btn btn-default pull-right' ) ); + get_admin_url( 'ctrl=widgets&blog='.$Blog->ID.'&action=new_container&container_type=shared-sub&skin_type='.get_param( 'skin_type' ) ), T_('Add Shared Sub-Container').' »', 3, 4, array( 'class' => 'action_icon hoverlink btn btn-default pull-right' ) ); echo '
    '; display_containers( get_param( 'skin_type' ), 'shared-sub' ); echo '
    '; diff --git a/inc/widgets/views/_widget_list_available.view.php b/inc/widgets/views/_widget_list_available.view.php index a089594ee38..b2d12f12c75 100644 --- a/inc/widgets/views/_widget_list_available.view.php +++ b/inc/widgets/views/_widget_list_available.view.php @@ -95,17 +95,13 @@ ), 'menu_item' => array( 'basic_menu_link', // Menu link or button - 'msg_menu_link', // Messaging Menu link or button - 'flag_menu_link', // Flagged Items Menu link or button - 'profile_menu_link', // My Profile Menu link or button 'embed_menu', // Embed Menu 'colls_list_public', // Collections list 'colls_list_owner', // Same owner's collections list - 'coll_common_links', // Common Navigation Links - 'user_tools', // User Tools ), 'navigation' => array( 'breadcrumb_path', // Breadcrumb Path + 'request_title', // Request Title 'coll_search_form', // Search Form 'site_logo', // Site logo 'cat_title', // Category Title @@ -117,6 +113,7 @@ 'coll_category_list', // Category list 'content_hierarchy', // Content Hierarchy 'coll_tag_cloud', // Tag cloud + 'coll_item_list_sort_order', // Sort order // Plugin: Calendar // Plugin: Date Archives ), @@ -156,6 +153,7 @@ 'item_vote', // Voting 'item_seen_by', // Seen by 'item_workflow', // Workflow Properties + 'item_checklist_lines', // Checklist Lines 'item_comment_form', // Comment Form 'item_comment_feed_link', // Comment Feed Link 'item_comment_notification', // Comment Notification @@ -280,4 +278,4 @@ { // End of customizer content: echo '
    '; } -?> \ No newline at end of file +?> diff --git a/inc/widgets/widgets.ctrl.php b/inc/widgets/widgets.ctrl.php index f159c235d4d..b6bb230a6f6 100644 --- a/inc/widgets/widgets.ctrl.php +++ b/inc/widgets/widgets.ctrl.php @@ -53,7 +53,7 @@ // Note: we may still have permission to edit categories!! $Messages->add( TB_('Sorry, you have no permission to edit collection properties.'), 'error' ); // Redirect to collections list: - header_redirect( $admin_url.'?ctrl=collections' ); + header_redirect( get_admin_url( 'ctrl=collections', '&' ) ); // EXITED. } @@ -180,7 +180,7 @@ { case 'js' : // js response needed // fp> when does this happen -- should be documented - if( !$current_User->check_perm( 'blog_properties', 'edit', false, $blog ) ) + if( ! check_user_perm( 'blog_properties', 'edit', false, $blog ) ) { // user doesn't have permissions $Messages->add( TB_('You do not have permission to perform this action' ) ); // fp>does this only happen when we try to edit settings. The hardcoded 'closeWidgetSettings' response looks bad. @@ -190,7 +190,7 @@ case 'normal': default : // take usual approach - $current_User->check_perm( 'blog_properties', 'edit', true, $blog ); + check_user_perm( 'blog_properties', 'edit', true, $blog ); // Initialize JS for color picker field on the edit plugin settings form: init_colorpicker_js(); } @@ -369,7 +369,7 @@ case 'normal' : default : // take usual action - header_redirect( '?ctrl=widgets&action=edit&wi_ID='.$edited_ComponentWidget->ID.( $mode == 'customizer' ? '&mode=customizer' : '' ) ); + header_redirect( get_admin_url( 'ctrl=widgets&action=edit&wi_ID='.$edited_ComponentWidget->ID.( $mode == 'customizer' ? '&mode=customizer' : '' ), '&' ) ); break; } break; @@ -418,7 +418,7 @@ } if( $action == 'update_edit' ) { // Stay on edit widget form: - header_redirect( $admin_url.'?ctrl=widgets&blog='.$Blog->ID.'&action=edit&wi_ID='.$edited_ComponentWidget->ID.'&display_mode='.$display_mode, 303 ); + header_redirect( get_admin_url( 'ctrl=widgets&blog='.$Blog->ID.'&action=edit&wi_ID='.$edited_ComponentWidget->ID.'&display_mode='.$display_mode, '&' ), 303 ); } else { // If $action == 'update' @@ -429,7 +429,7 @@ // (e.g. used to display new auto created sub-container by widget "Columns(Sub-Containers)" - subcontainer_row_Widget) $Session->set( 'refresh_customizer_window', 1 ); } - header_redirect( $admin_url.'?ctrl=widgets&blog='.$Blog->ID, 303 ); + header_redirect( get_admin_url( 'ctrl=widgets&blog='.$Blog->ID, '&' ), 303 ); } } elseif( $display_mode == 'js' ) @@ -542,7 +542,7 @@ // EXITS: send_javascript_message( array( 'doToggle' => array( $edited_ComponentWidget->ID, (int)! $enabled, $plugin_disabled ) ) ); } - header_redirect( $admin_url.'?ctrl=widgets&blog='.$Blog->ID, 303 ); + header_redirect( get_admin_url( 'ctrl=widgets&blog='.$Blog->ID, '&' ), 303 ); break; case 'cache_enable': @@ -579,7 +579,7 @@ $edited_ComponentWidget->get_cache_status( true ), ) ) ); } - header_redirect( $admin_url.'?ctrl=widgets&blog='.$Blog->ID, 303 ); + header_redirect( get_admin_url( 'ctrl=widgets&blog='.$Blog->ID, '&' ), 303 ); break; case 'activate': @@ -615,7 +615,7 @@ if( $mode == 'customizer' ) { // Set an URL to redirect back to customizer mode: - $redirect_to = $admin_url.'?ctrl=widgets&blog='.$Blog->ID.'&skin_type='.$skin_type.'&action=customize&mode=customizer'; + $redirect_to = get_admin_url( 'ctrl=widgets&blog='.$Blog->ID.'&skin_type='.$skin_type.'&action=customize&mode=customizer', '&' ); $WidgetContainerCache = & get_WidgetContainerCache(); if( $WidgetContainer = & $WidgetContainerCache->get_by_ID( $wico_ID, false, false ) ) { @@ -624,7 +624,7 @@ } else { // Set an URL to redirect to normal mode: - $redirect_to = $admin_url.'?ctrl=widgets&blog='.$Blog->ID; + $redirect_to = get_admin_url( 'ctrl=widgets&blog='.$Blog->ID, '&' ); } header_redirect( $redirect_to, 303 ); @@ -652,7 +652,7 @@ case 'normal' : default : // take usual action // PREVENT RELOAD & Switch to list mode: - header_redirect( '?ctrl=widgets&blog='.$blog ); + header_redirect( get_admin_url( 'ctrl=widgets&blog='.$blog, '&' ) ); break; } break; @@ -750,7 +750,7 @@ // Save to DB, and display correpsonding messages: $Blog->db_save_main_containers( true, $skin_type ); - header_redirect( '?ctrl=widgets&blog='.$Blog->ID.'&skin_type='.$skin_type, 303 ); + header_redirect( get_admin_url( 'ctrl=widgets&blog='.$Blog->ID.'&skin_type='.$skin_type, '&' ), 303 ); break; case 'create_container': @@ -777,11 +777,11 @@ } if( $mode == 'customizer' ) { // Redirect back to customizer mode: - $redirect_to = $admin_url.'?ctrl=widgets&blog='.$Blog->ID.'&skin_type='.$skin_type.'&action=customize&mode=customizer'; + $redirect_to = get_admin_url( 'ctrl=widgets&blog='.$Blog->ID.'&skin_type='.$skin_type.'&action=customize&mode=customizer', '&' ); } else { // Redirect back to back-office widgets list: - $redirect_to = $admin_url.'?ctrl=widgets&blog='.$Blog->ID.'&skin_type='.$edited_WidgetContainer->get( 'skin_type' ); + $redirect_to = get_admin_url( 'ctrl=widgets&blog='.$Blog->ID.'&skin_type='.$edited_WidgetContainer->get( 'skin_type' ), '&' ); } header_redirect( $redirect_to, 303 ); } @@ -802,11 +802,11 @@ if( $mode == 'customizer' ) { // Redirect back to customizer mode: - $redirect_to = $admin_url.'?ctrl=widgets&blog='.$blog.'&skin_type='.$skin_type.'&action=customize&mode=customizer'; + $redirect_to = get_admin_url( 'ctrl=widgets&blog='.$blog.'&skin_type='.$skin_type.'&action=customize&mode=customizer', '&' ); } else { // Redirect back to back-office widgets list: - $redirect_to = $admin_url.'?ctrl=widgets&blog='.$blog; + $redirect_to = get_admin_url( 'ctrl=widgets&blog='.$blog, '&' ); } header_redirect( $redirect_to, 303 ); break; @@ -835,7 +835,7 @@ } // Redirect back to back-office widgets list: - header_redirect( $admin_url.'?ctrl=widgets&blog='.$Blog->ID.'&skin_type='.$edited_WidgetContainer->get( 'skin_type' ), 303 ); + header_redirect( get_admin_url( 'ctrl=widgets&blog='.$Blog->ID.'&skin_type='.$edited_WidgetContainer->get( 'skin_type' ), '&' ), 303 ); break; default: @@ -887,8 +887,8 @@ var widget_crumb_url_param = \''.url_crumb( 'widget' ).'\'; - var b2evo_dispatcher_url = "'.$admin_url.'";' ); - require_js( '#jqueryUI#' ); // auto requires jQuery + var b2evo_dispatcher_url = "'.get_admin_url().'";' ); + require_js_defer( '#jqueryUI#' ); // auto requires jQuery require_css( 'blog_widgets.css' ); init_tokeninput_js(); init_hotkeys_js( 'blog', array( 'ctrl+s', 'command+s', 'ctrl+enter', 'command+enter' ) ); @@ -901,8 +901,8 @@ $Session->delete( 'refresh_customizer_window' ); } - $AdminUI->breadcrumbpath_init( true, array( 'text' => TB_('Collections'), 'url' => $admin_url.'?ctrl=collections' ) ); - $AdminUI->breadcrumbpath_add( TB_('Widgets'), $admin_url.'?ctrl=widgets&blog=$blog$' ); + $AdminUI->breadcrumbpath_init( true, array( 'text' => T_('Collections'), 'url' => get_admin_url( 'ctrl=collections' ) ) ); + $AdminUI->breadcrumbpath_add( T_('Widgets'), get_admin_url( 'ctrl=widgets&blog=$blog$' ) ); // Set an url for manual page: $AdminUI->set_page_manual_link( 'widget-settings' ); diff --git a/inc/widgets/widgets/_basic_menu_link.widget.php b/inc/widgets/widgets/_basic_menu_link.widget.php index e6b2244b4f6..eb07def70ee 100644 --- a/inc/widgets/widgets/_basic_menu_link.widget.php +++ b/inc/widgets/widgets/_basic_menu_link.widget.php @@ -115,8 +115,8 @@ function get_param_definitions( $params ) $current_link_type = $this->get_param( 'link_type', $default_link_type ); // Check if field "Collection ID" is disabled because of link type and site uses only one fixed collection for profile pages: - $coll_id_is_disabled = ( in_array( $current_link_type, array( 'ownercontact', 'owneruserinfo', 'myprofile', 'profile', 'avatar' ) ) - && $msg_Blog = & get_setting_Blog( 'msg_blog_ID' ) ); + $msg_Blog = & get_setting_Blog( 'msg_blog_ID' ); + $coll_id_is_disabled = in_array( $current_link_type, array( 'ownercontact', 'owneruserinfo', 'myprofile', 'profile', 'avatar', 'messages', 'contacts' ) ); load_funcs( 'files/model/_image.funcs.php' ); @@ -128,6 +128,21 @@ function get_param_definitions( $params ) 'options' => $this->link_types, 'defaultvalue' => $default_link_type, ), + 'coll_logo_size' => array( + 'type' => 'select', + 'label' => T_('Collection logo before link text'), + 'options' => get_available_thumb_sizes( T_('No logo') ), + 'defaultvalue' => '', + 'hide' => in_array( $current_link_type, array( 'item', 'admin', 'url' ) ), + ), + 'profile_picture_size' => array( + 'label' => T_('Profile picture before text'), + 'note' => '', + 'type' => 'select', + 'options' => get_available_thumb_sizes( T_('No picture') ), + 'defaultvalue' => '', + 'hide' => ! in_array( $current_link_type, array( 'logout', 'myprofile', 'visits', 'profile', 'avatar', 'useritems', 'usercomments' ) ), + ), 'link_text' => array( 'label' => T_('Link text'), 'note' => T_( 'Text to use for the link (leave empty for default).' ), @@ -135,23 +150,25 @@ function get_param_definitions( $params ) 'size' => 20, 'defaultvalue' => '', ), - 'coll_logo_size' => array( - 'type' => 'select', - 'label' => T_('Collection logo before link text'), - 'options' => get_available_thumb_sizes( T_('No logo') ), - 'defaultvalue' => '', + 'show_badge' => array( + 'label' => T_('Show Badge'), + 'note' => T_('Show a badge with count.'), + 'type' => 'checkbox', + 'defaultvalue' => true, + 'hide' => ! in_array( $current_link_type, array( 'messages', 'flagged' ) ), ), 'blog_ID' => array( 'label' => T_('Collection ID'), 'note' => T_( 'Leave empty for current collection.' ) - .( $coll_id_is_disabled ? ' '.sprintf( T_('The site is configured to always use collection %s for profiles/messaging functions.'), + .( $msg_Blog ? ' ' : '' ), 'type' => 'integer', 'allow_empty' => true, 'size' => 5, 'defaultvalue' => '', - 'disabled' => $coll_id_is_disabled ? 'disabled' : false, + 'disabled' => $coll_id_is_disabled && $msg_Blog ? 'disabled' : false, 'hide' => in_array( $current_link_type, array( 'item', 'admin', 'url' ) ), ), 'cat_ID' => array( @@ -163,16 +180,6 @@ function get_param_definitions( $params ) 'defaultvalue' => '', 'hide' => ! in_array( $current_link_type, array( 'recentposts', 'postnew' ) ), ), - 'visibility' => array( - 'label' => T_( 'Visibility' ), - 'note' => '', - 'type' => 'radio', - 'options' => array( - array( 'always', T_( 'Always show (cacheable)') ), - array( 'access', T_( 'Only show if access is allowed (not cacheable)' ) ) ), - 'defaultvalue' => 'always', - 'field_lines' => true, - ), // fp> TODO: ideally we would have a link icon to go click on the destination... 'item_ID' => array( 'label' => T_('Item ID'), @@ -191,6 +198,17 @@ function get_param_definitions( $params ) 'defaultvalue' => '', 'hide' => ( $current_link_type != 'url' ), ), + 'show_to' => array( + 'label' => T_('Show to'), + 'note' => '', + 'type' => 'radio', + 'options' => array( array( 'any', T_('All users') ), + array( 'loggedin', T_('Logged in users') ), + array( 'perms', T_('Users with permissions only') ) ), + 'defaultvalue' => 'perms', + 'field_lines' => true, + 'hide' => ! in_array( $current_link_type, array( 'messages', 'contacts' ) ), + ), 'highlight_current' => array( 'label' => T_('Highlight current'), 'note' => '', @@ -202,6 +220,23 @@ function get_param_definitions( $params ) 'defaultvalue' => 'yes', 'field_lines' => true, ), + 'hide_empty' => array( + 'label' => T_('Hide if empty'), + 'note' => T_('Check to hide this menu if the list is empty.'), + 'type' => 'checkbox', + 'defaultvalue' => false, + 'hide' => ( $current_link_type != 'flagged' ), + ), + 'visibility' => array( + 'label' => T_( 'Visibility' ), + 'note' => '', + 'type' => 'radio', + 'options' => array( + array( 'always', T_( 'Always show (cacheable)') ), + array( 'access', T_( 'Only show if access is allowed (not cacheable)' ) ) ), + 'defaultvalue' => 'always', + 'field_lines' => true, + ), ), parent::get_param_definitions( $params ) ); return $r; @@ -218,14 +253,44 @@ function get_edit_form_javascript() return 'jQuery( "#'.$this->get_param_prefix().'link_type" ).change( function() { var link_type_value = jQuery( this ).val(); + // Hide/Show Profile picture size: + jQuery( "#ffield_'.$this->get_param_prefix().'profile_picture_size" ).toggle( link_type_value == "logout" || + link_type_value == "myprofile" || + link_type_value == "visits" || + link_type_value == "profile" || + link_type_value == "avatar" || + link_type_value == "useritems" || + link_type_value == "usercomments" ); + if( link_type_value == "myprofile" && jQuery( "#'.$this->get_param_prefix().'profile_picture_size" ).val() == "" ) + { // Set default picture size for "View my profile": + jQuery( "#'.$this->get_param_prefix().'profile_picture_size" ).val( "crop-top-15x15" ); + } // Hide/Show collection ID: - jQuery( "#ffield_'.$this->get_param_prefix().'blog_ID" ).toggle( link_type_value != "item" && link_type_value != "admin" && link_type_value != "url" ); + jQuery( "#ffield_'.$this->get_param_prefix().'blog_ID, #ffield_'.$this->get_param_prefix().'coll_logo_size" ).toggle( link_type_value != "item" && link_type_value != "admin" && link_type_value != "url" ); + if( jQuery( ".evo_setting_coll_disabled" ).length ) + { // Hide/Show info for disabled collection: + var coll_disabled = link_type_value == "ownercontact" || + link_type_value == "owneruserinfo" || + link_type_value == "myprofile" || + link_type_value == "profile" || + link_type_value == "avatar" || + link_type_value == "messages" || + link_type_value == "contacts"; + jQuery( ".evo_setting_coll_disabled" ).toggle( coll_disabled ); + jQuery( "#'.$this->get_param_prefix().'blog_ID" ).prop( "disabled", coll_disabled ); + } // Hide/Show category ID: jQuery( "#ffield_'.$this->get_param_prefix().'cat_ID" ).toggle( link_type_value == "recentposts" || link_type_value == "postnew" ); // Hide/Show item ID: jQuery( "#ffield_'.$this->get_param_prefix().'item_ID" ).toggle( link_type_value == "item" ); // Hide/Show URL: jQuery( "#ffield_'.$this->get_param_prefix().'url" ).toggle( link_type_value == "url" ); + // Hide/Show setting "Show to": + jQuery( "#ffield_'.$this->get_param_prefix().'show_to" ).toggle( link_type_value == "messages" || link_type_value == "contacts" ); + // Hide/Show setting "Show Badge": + jQuery( "#ffield_'.$this->get_param_prefix().'show_badge" ).toggle( link_type_value == "messages" || link_type_value == "flagged" ); + // Hide/Show setting "Hide if empty": + jQuery( "#ffield_'.$this->get_param_prefix().'hide_empty" ).toggle( link_type_value == "flagged" ); } );'; } @@ -262,6 +327,16 @@ function display( $params ) $this->init_display( $params ); + if( isset( $this->disp_params['link_text_'.$this->disp_params['link_type']] ) ) + { // Use custom link text per type from skin side: + // (used by site skins with param like 'link_text_myprofile' => '$login$' where we need to force friendly username to login) + $link_text = $this->disp_params['link_text_'.$this->disp_params['link_type']]; + } + else + { // Use normal link text: + $link_text = $this->disp_params['link_text']; + } + // Initialize Menu Entry object to build a menu link/button: load_class( 'menus/model/_sitemenuentry.class.php', 'SiteMenuEntry' ); $SiteMenuEntry = new SiteMenuEntry(); @@ -269,11 +344,15 @@ function display( $params ) $SiteMenuEntry->set( 'cat_ID', $this->disp_params['cat_ID'] ); $SiteMenuEntry->set( 'item_ID', $this->disp_params['item_ID'] ); $SiteMenuEntry->set( 'coll_logo_size', $this->disp_params['coll_logo_size'] ); + $SiteMenuEntry->set( 'user_pic_size', $this->disp_params['profile_picture_size'] ); $SiteMenuEntry->set( 'type', $this->disp_params['link_type'] ); - $SiteMenuEntry->set( 'text', $this->disp_params['link_text'] ); + $SiteMenuEntry->set( 'text', $link_text ); $SiteMenuEntry->set( 'url', $this->disp_params['link_href'] ); $SiteMenuEntry->set( 'visibility', $this->disp_params['visibility'] ); + $SiteMenuEntry->set( 'access', $this->disp_params['show_to'] ); + $SiteMenuEntry->set( 'show_badge', $this->disp_params['show_badge'] ); $SiteMenuEntry->set( 'highlight', ( $this->disp_params['highlight_current'] == 'yes' ) ); + $SiteMenuEntry->set( 'hide_empty', $this->disp_params['hide_empty'] ); if( ! ( $entry_Blog = & $SiteMenuEntry->get_Blog() ) ) { // We cannot use this widget without a current collection: @@ -283,7 +362,7 @@ function display( $params ) if( ! ( $url = $SiteMenuEntry->get_url() ) ) { // Don't display this menu entry because of some restriction for current User or by general settings: - $this->display_debug_message(); + $this->display_debug_message( empty( $SiteMenuEntry->url_error ) ? '' : 'Hidden('.$SiteMenuEntry->url_error.')' ); return false; } @@ -329,6 +408,14 @@ function display( $params ) $this->BlockCache->abort_collect(); } break; + + case 'messages': + case 'flagged': + if( $SiteMenuEntry->get( 'show_badge' ) && isset( $this->BlockCache ) ) + { // Do not cache if bage is displayed because the number of unread messages are always changing: + $this->BlockCache->abort_collect(); + } + break; } // Display a layout with menu link: diff --git a/inc/widgets/widgets/_cat_content_list.widget.php b/inc/widgets/widgets/_cat_content_list.widget.php index a8fb2030482..7d625152b47 100644 --- a/inc/widgets/widgets/_cat_content_list.widget.php +++ b/inc/widgets/widgets/_cat_content_list.widget.php @@ -90,16 +90,16 @@ function get_desc() */ function get_param_definitions( $params ) { - global $current_User, $admin_url; + global $admin_url; // Get available templates: $context = 'content_list_master'; $TemplateCache = & get_TemplateCache(); $TemplateCache->load_by_context( $context ); $template_options = array( NULL => T_('No template') ) + $TemplateCache->get_code_option_array(); - $template_input_suffix = ( is_logged_in() && $current_User->check_perm( 'options', 'edit' ) ? ' ' + $template_input_suffix = ( check_user_perm( 'options', 'edit' ) ? ' ' .action_icon( '', 'edit', $admin_url.'?ctrl=templates&context='.$context, NULL, NULL, NULL, - array( 'onclick' => 'return b2template_list_highlight( this )' ), + array( 'onclick' => 'return b2template_list_highlight( this )', 'target' => '_blank' ), array( 'title' => T_('Manage templates').'...' ) ) : '' ); // Get all catgories of the widget Collection: @@ -288,11 +288,38 @@ function display_subcat_template( $param_Chapter, $level, $params = array() ) */ function display_item_template( $param_Item, $level, $params = array() ) { + global $Item; + if( empty( $params['item_template'] ) ) { // No template is provided for listing an item: return; } + $TemplateCache = & get_TemplateCache(); + $item_template = $params['item_template']; + + // Check if the param Item is currently active: + $highlight_current_item = ( ! empty( $Item ) && $param_Item->ID == $Item->ID ); + + if( $highlight_current_item ) + { // Get template for currently active Item: + $active_item_template = isset( $params['active_item_template'] ) ? $params['active_item_template'] : $item_template; + if( $active_item_template != $item_template && + ( $active_item_Template = & $TemplateCache->get_by_code( $active_item_template, false, false ) ) ) + { // Use active item template when it is different and found in DB: + $item_template = $active_item_template; + } + } + elseif( $param_Item->main_cat_ID != $params['chapter_ID'] ) + { // Get template for crossposted Item: + $crossposted_item_template = isset( $params['crossposted_item_template'] ) ? $params['crossposted_item_template'] : $item_template; + if( $crossposted_item_template != $item_template && + ( $crossposted_item_Template = & $TemplateCache->get_by_code( $crossposted_item_template, false, false ) ) ) + { // Use crossposted item template when it is different and found in DB: + $item_template = $crossposted_item_template; + } + } + $item_template_params = array_merge( $params, array( // In case of cross-posting, we EXPECT tp navigate in same category and same collection if possible: 'post_navigation' => 'same_category', // Stay in the same category if Item is cross-posted @@ -301,7 +328,7 @@ function display_item_template( $param_Item, $level, $params = array() ) ) ); // Render Item by quick template: - echo render_template_code( $params['item_template'], $item_template_params, array( 'Item' => $param_Item ) ); + echo render_template_code( $item_template, $item_template_params, array( 'Item' => $param_Item ) ); } } diff --git a/inc/widgets/widgets/_coll_activity_stats.widget.php b/inc/widgets/widgets/_coll_activity_stats.widget.php index dec0d30d28a..60f058b63ed 100644 --- a/inc/widgets/widgets/_coll_activity_stats.widget.php +++ b/inc/widgets/widgets/_coll_activity_stats.widget.php @@ -14,7 +14,6 @@ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); load_class( 'widgets/model/_widget.class.php', 'ComponentWidget' ); -init_jqplot_js( 'blog' ); /** * coll_activity_stats_Widget Class. @@ -137,7 +136,7 @@ function init_display( $params ) { parent::init_display( $params ); - $this->disp_params['block_body_start'] = ''; + $this->disp_params['block_body_start'] = '
    '; $this->disp_params['block_body_end'] = '
    '; } @@ -268,81 +267,18 @@ function display( $params ) echo $this->disp_params['block_body_start']; - CanvasBarsChart( $chart, 'resize_coll_activity_stat_widget' ); + CanvasBarsChart( $chart, 'resize_coll_activity_stat_widget', 'activity_stats_widget_'.$this->ID ); echo $this->disp_params['block_body_end']; echo $this->disp_params['block_end']; - ?> - - \ No newline at end of file +?> diff --git a/inc/widgets/widgets/_coll_common_links.widget.php b/inc/widgets/widgets/_coll_common_links.widget.php deleted file mode 100644 index 8148ed65d2a..00000000000 --- a/inc/widgets/widgets/_coll_common_links.widget.php +++ /dev/null @@ -1,281 +0,0 @@ - why are "STRONG" tags hardcoded here? can this get dropped/removed? should the style - * get adjusted to use font-weight:bold then? - * fp> yes but make sure to put the font-weight in a place where it applies to all (existing) skins by default; e-g blog_base.css - * - * @package evocore - */ -class coll_common_links_Widget extends ComponentWidget -{ - var $icon = 'align-justify'; - - /** - * Constructor - */ - function __construct( $db_row = NULL ) - { - // Call parent constructor: - parent::__construct( $db_row, 'core', 'coll_common_links' ); - } - - - /** - * Get help URL - * - * @return string URL - */ - function get_help_url() - { - return get_manual_url( 'common-navigation-links-widget' ); - } - - - /** - * Get name of widget - */ - function get_name() - { - return T_('Common Navigation Links'); - } - - - /** - * Get a very short desc. Used in the widget list. - */ - function get_short_desc() - { - return format_to_output($this->disp_params['title']); - } - - - /** - * Get short description - */ - function get_desc() - { - return T_('DEPRECATED').' - '.T_('Display these links: Recently, Archives, Categories, Latest Comments'); - } - - - /** - * Get definitions for editable params - * - * @see Plugin::GetDefaultSettings() - * @param local params like 'for_editing' => true - */ - function get_param_definitions( $params ) - { - $r = array_merge( array( - 'title' => array( - 'label' => T_('Block title'), - 'note' => T_( 'Title to display in your skin.' ), - 'size' => 40, - 'defaultvalue' => '', - ), - 'show_home' => array( - 'type' => 'checkbox', - 'label' => T_('Show "Home"'), - 'note' => T_('Go to the blog\'s home.'), - 'defaultvalue' => 1, - ), - 'show_recently' => array( - 'type' => 'checkbox', - 'label' => T_('Show "Recently"'), - 'note' => T_('Go to the most recent posts (depends on default sort order).'), - 'defaultvalue' => 1, - ), - 'show_search' => array( - 'type' => 'checkbox', - 'label' => T_('Show "Search"'), - 'note' => T_('Go to the search page.'), - 'defaultvalue' => 0, - ), - 'show_postidx' => array( - 'type' => 'checkbox', - 'label' => T_('Show "Post index"'), - 'note' => T_('Go to the post index.'), - 'defaultvalue' => 0, - ), - 'show_archives' => array( - 'type' => 'checkbox', - 'label' => T_('Show "Archives"'), - 'note' => T_('Go to the monthly/weekly/daily archive list.'), - 'defaultvalue' => 1, - ), - 'show_categories' => array( - 'type' => 'checkbox', - 'label' => T_('Show "Categories"'), - 'note' => T_('Go to the category tree.'), - 'defaultvalue' => 1, - ), - 'show_mediaidx' => array( - 'type' => 'checkbox', - 'label' => T_('Show "Photo index"'), - 'note' => T_('Go to the photo index / contact sheet.'), - 'defaultvalue' => 0, - ), - 'show_latestcomments' => array( - 'type' => 'checkbox', - 'label' => T_('Show "Latest comments"'), - 'note' => T_('Go to the latest comments.'), - 'defaultvalue' => 1, - ), - 'show_owneruserinfo' => array( - 'type' => 'checkbox', - 'label' => T_('Show "Owner details"'), - 'note' => T_('Go to user info about the blog owner.'), - 'defaultvalue' => 0, - ), - 'show_ownercontact' => array( - 'type' => 'checkbox', - 'label' => T_('Show "Contact"'), - 'note' => T_('Go to message form to contact the blog owner.'), - 'defaultvalue' => 0, - ), - 'show_sitemap' => array( - 'type' => 'checkbox', - 'label' => T_('Show "Site map"'), - 'note' => T_('Go to site map (HTML version).'), - 'defaultvalue' => 0, - ), - ), parent::get_param_definitions( $params ) ); - - return $r; - - } - - - /** - * Display the widget! - * - * @param array MUST contain at least the basic display params - */ - function display( $params ) - { - /** - * @var Blog - */ - global $Collection, $Blog; - - $this->init_display( $params ); - - // Collection common links: - echo $this->disp_params['block_start']; - - // Display title if requested - $this->disp_title(); - - echo $this->disp_params['block_body_start']; - - echo $this->disp_params['list_start']; - - if( $this->disp_params['show_home'] ) - { - echo $this->disp_params['item_start']; - echo ''.T_('Home').''; - echo $this->disp_params['item_end']; - } - - if( $this->disp_params['show_recently'] ) - { - echo $this->disp_params['item_start']; - echo ''.T_('Recently').''; - echo $this->disp_params['item_end']; - } - - if( $this->disp_params['show_search'] ) - { - echo $this->disp_params['item_start']; - echo ''.T_('Search').''; - echo $this->disp_params['item_end']; - } - - if( $this->disp_params['show_postidx'] ) - { - echo $this->disp_params['item_start']; - echo ''.T_('Post index').''; - echo $this->disp_params['item_end']; - } - - if( $this->disp_params['show_archives'] ) - { - // fp> TODO: don't display this if archives plugin not installed... or depluginize archives (I'm not sure) - echo $this->disp_params['item_start']; - echo ''.T_('Archives').''; - echo $this->disp_params['item_end']; - } - - if( $this->disp_params['show_categories'] ) - { - echo $this->disp_params['item_start']; - echo ''.T_('Categories').''; - echo $this->disp_params['item_end']; - } - - if( $this->disp_params['show_mediaidx'] ) - { - echo $this->disp_params['item_start']; - echo ''.T_('Photo index').''; - echo $this->disp_params['item_end']; - } - - if( $this->disp_params['show_latestcomments'] && $Blog->get_setting( 'comments_latest' ) ) - { // Display link to latest comments if this feature is enabled for current blog - echo $this->disp_params['item_start']; - echo ''.T_('Latest comments').''; - echo $this->disp_params['item_end']; - } - - if( $this->disp_params['show_owneruserinfo'] ) - { - echo $this->disp_params['item_start']; - echo ''.T_('Owner details').''; - echo $this->disp_params['item_end']; - } - - if( $this->disp_params['show_ownercontact'] && $url = $Blog->get_contact_url() ) - { // owner allows contact: - echo $this->disp_params['item_start']; - echo 'get_setting( 'msgform_nofollowto' ) ? ' rel="nofollow"' : '' ).'>'.T_('Contact').''; - echo $this->disp_params['item_end']; - } - - if( $this->disp_params['show_sitemap'] ) - { - echo $this->disp_params['item_start']; - echo ''.T_('Site map').''; - echo $this->disp_params['item_end']; - } - - echo $this->disp_params['list_end']; - - echo $this->disp_params['block_body_end']; - - echo $this->disp_params['block_end']; - - return true; - } -} - -?> \ No newline at end of file diff --git a/inc/widgets/widgets/_coll_current_filters.widget.php b/inc/widgets/widgets/_coll_current_filters.widget.php index 8060f494697..8aedccd54a1 100644 --- a/inc/widgets/widgets/_coll_current_filters.widget.php +++ b/inc/widgets/widgets/_coll_current_filters.widget.php @@ -153,6 +153,7 @@ function display( $params ) $filters = implode( ' '.T_('AND').' ', $params['ItemList']->get_filter_titles( array(), array( 'categories_text' => '', 'categories_nor_text' => T_('NOT').' ', + 'statuses_nor_text' => T_('NOT').' ', 'tags_nor_text' => T_('NOT').' ', 'authors_nor_text' => T_('NOT').' ', 'group_mask' => '$filter_items$', diff --git a/inc/widgets/widgets/_coll_featured_intro.widget.php b/inc/widgets/widgets/_coll_featured_intro.widget.php index 313b6e48392..e53b888c7f6 100644 --- a/inc/widgets/widgets/_coll_featured_intro.widget.php +++ b/inc/widgets/widgets/_coll_featured_intro.widget.php @@ -203,7 +203,7 @@ function display( $params ) { // We have a featured/intro post to display: $item_style = ''; $LinkOwner = new LinkItem( $Item ); - $LinkList = $LinkOwner->get_attachment_LinkList( 1, 'cover' ); + $LinkList = $LinkOwner->get_attachment_LinkList( 1, 'background' ); if( ! empty( $LinkList ) && $Link = & $LinkList->get_next() && $File = & $Link->get_File() && diff --git a/inc/widgets/widgets/_coll_item_list.widget.php b/inc/widgets/widgets/_coll_item_list.widget.php index 9669496c400..67ac1117316 100644 --- a/inc/widgets/widgets/_coll_item_list.widget.php +++ b/inc/widgets/widgets/_coll_item_list.widget.php @@ -44,7 +44,7 @@ function __construct( $db_row = NULL ) */ function get_param_definitions( $params ) { - global $current_User, $admin_url; + global $admin_url; // Get available templates: $context = 'content_list_master'; @@ -82,12 +82,18 @@ function get_param_definitions( $params ) 'type' => 'select', 'options' => $template_options, 'defaultvalue' => NULL, - 'input_suffix' => ( is_logged_in() && $current_User->check_perm( 'options', 'edit' ) ? ' ' + 'input_suffix' => ( check_user_perm( 'options', 'edit' ) ? ' ' .action_icon( '', 'edit', $admin_url.'?ctrl=templates&context='.$context, NULL, NULL, NULL, - array( 'onclick' => 'return b2template_list_highlight( this )' ), + array( 'onclick' => 'return b2template_list_highlight( this )', 'target' => '_blank' ), array( 'title' => T_('Manage templates').'...' ) ) : '' ), 'class' => 'evo_template_select', ), + 'highlight_current' => array( + 'label' => T_('Highlight current'), + 'note' => T_('Check this to highlight the currently displayed item.'), + 'type' => 'checkbox', + 'defaultvalue' => 1, + ), 'title_link' => array( 'label' => T_('Link to blog'), 'note' => T_('Link the block title to the blog?'), @@ -322,10 +328,14 @@ function get_param_definitions( $params ) ), parent::get_param_definitions( $params ) ); if( isset( $r['allow_blockcache'] ) ) - { // Disable "allow blockcache" because this widget uses the selected items - $r['allow_blockcache']['defaultvalue'] = false; - $r['allow_blockcache']['disabled'] = 'disabled'; - $r['allow_blockcache']['note'] = T_('This widget cannot be cached in the block cache.'); + { + if( $this->get_param( 'highlight_current', 1 ) ) + { // Disable "allow blockcache" because this widget uses the selected items: + $r['allow_blockcache']['defaultvalue'] = false; + $r['allow_blockcache']['disabled'] = 'disabled'; + } + // Additional note when random order is used: + $r['allow_blockcache']['note'] .= ' '.T_('If you use random order and you cache, the random order will stay the same after the initial cache filling.').''; } return $r; @@ -339,7 +349,12 @@ function get_param_definitions( $params ) */ function get_edit_form_javascript() { - return get_post_orderby_js( $this->get_param_prefix().'order_by', $this->get_param_prefix().'order_dir' ); + return get_post_orderby_js( $this->get_param_prefix().'order_by', $this->get_param_prefix().'order_dir' ) + // Disable option "Allow caching" when option "Highlight current" is used: + .'jQuery( "#'.$this->get_param_prefix().'highlight_current" ).click( function() + { + jQuery( "#'.$this->get_param_prefix().'allow_blockcache" ).prop( "disabled", jQuery( this ).prop( "checked" ) ); + } );'; } @@ -424,6 +439,22 @@ function get_desc() } + /** + * Prepare display params + * + * @param array MUST contain at least the basic display params + */ + function init_display( $params ) + { + parent::init_display( $params ); + + if( $this->disp_params['highlight_current'] ) + { // Disable block caching for this widget when it highlights the selected items: + $this->disp_params['allow_blockcache'] = 0; + } + } + + /** * Display the widget! * @@ -781,6 +812,7 @@ function get_cache_keys() 'set_coll_ID' => $Blog->ID, // Have the settings of the blog changed ? (ex: new skin) 'cont_coll_ID' => empty( $blog_ID ) ? $Blog->ID : $blog_ID, // Has the content of the displayed blog changed ? 'template_code'=> $this->get_param( 'template' ), // Has the Template changed? + 'master_template' => true, // This widget cache must be invalidated on updating of any Template because it may has a Master Template. ); } } diff --git a/inc/widgets/widgets/_coll_item_list_sort_order.widget.php b/inc/widgets/widgets/_coll_item_list_sort_order.widget.php new file mode 100644 index 00000000000..e6e9730b798 --- /dev/null +++ b/inc/widgets/widgets/_coll_item_list_sort_order.widget.php @@ -0,0 +1,252 @@ + true + */ + function get_param_definitions( $params ) + { + // Initiliaze sort options for widget param from available sort options: + $sort_options = $this->get_sort_options(); + $widget_sort_options = array(); + foreach( $sort_options as $sort_key => $sort_title ) + { + $widget_sort_options[] = array( $sort_key, $sort_title, 1 ); + } + + $r = array_merge( array( + 'title' => array( + 'label' => T_('Title'), + 'size' => 40, + 'note' => T_('This is the title to display'), + 'defaultvalue' => '', + ), + 'allowed_orders' => array( + 'label' => T_('Allow'), + 'type' => 'checklist', + 'options' => $widget_sort_options, + ), + 'display_mode' => array( + 'type' => 'select', + 'label' => T_('Display as'), + 'options' => array( + 'dropdown' => T_('Dropdown menu'), + 'list' => T_('List'), + ), + 'defaultvalue' => 'dropdown', + ), + ), parent::get_param_definitions( $params ) ); + + if( isset( $r['allow_blockcache'] ) ) + { // Disable "allow blockcache" because this widget displays dynamic data: + $r['allow_blockcache']['defaultvalue'] = false; + $r['allow_blockcache']['disabled'] = 'disabled'; + $r['allow_blockcache']['note'] = T_('This widget cannot be cached in the block cache.'); + } + + return $r; + } + + + /** + * Request all required css and js files for this widget + */ + function request_required_files() + { + global $MainList; + + if( ! empty( $MainList ) && + ! $MainList->single_post && + $this->get_param( 'display_mode' ) == 'dropdown' ) + { // Load JS to sort items list: + require_js_defer( '#jquery#', 'blog', false, '#', 'footerlines' ); + require_js_defer( 'src/evo_init_widget_coll_item_list_sort_order.js', 'blog', false, '#', 'footerlines' ); + } + } + + + /** + * Get sort options + * + * @return array + */ + function get_sort_options() + { + $available_sort_options = get_available_sort_options(); + $sort_options = array(); + foreach( $available_sort_options as $sort_key => $sort_title ) + { + $sort_options[ $sort_key.':asc'] = $sort_title; + $sort_options[ $sort_key.':desc'] = $sort_title.' ('.T_('Reverse').')'; + } + + return $sort_options; + } + + + /** + * Display the widget! + * + * @param array MUST contain at least the basic display params + */ + function display( $params ) + { + global $MainList; + + $this->init_display( $params ); + + if( empty( $MainList ) ) + { // No items list to sort: + $this->display_debug_message( 'Widget "'.$this->get_name().'" is hidden because there is no items list on the current page.' ); + return false; + } + + if( $MainList->single_post ) + { // No need to sort single Item: + $this->display_debug_message( 'Widget "'.$this->get_name().'" is hidden because single item in list.' ); + return false; + } + + // Get all sort options: + $sort_options = $this->get_sort_options(); + + $allowed_orders = $this->get_param( 'allowed_orders' ); + foreach( $allowed_orders as $order_key => $order_is_allowed ) + { + if( ! isset( $sort_options[ $order_key ] ) || ! $order_is_allowed ) + { // Exclude disallowed order: + unset( $allowed_orders[ $order_key ] ); + } + } + + if( empty( $allowed_orders ) ) + { // No allowed sort ooptions + $this->display_debug_message( 'Widget "'.$this->get_name().'" is hidden because no sort oprions are allowed.' ); + return false; + } + + echo $this->disp_params['block_start']; + $this->disp_title(); + echo $this->disp_params['block_body_start']; + + switch( $this->get_param( 'display_mode' ) ) + { + case 'list': + echo $this->disp_params['list_start']; + foreach( $allowed_orders as $order_key => $order_enabled ) + { + $order = explode( ':', $order_key ); + $order_is_selected = ( $MainList->filters['orderby'] == $order[0] && strtolower( $MainList->filters['order'] ) == $order[1] ); + echo $order_is_selected ? $this->disp_params['item_selected_start'] : $this->disp_params['item_start']; + echo ''.$sort_options[ $order_key ].''; + echo $order_is_selected ? $this->disp_params['item_selected_end'] : $this->disp_params['item_end']; + } + echo $this->disp_params['list_end']; + break; + + default: // dropdown + echo ''; + break; + } + + echo $this->disp_params['block_body_end']; + echo $this->disp_params['block_end']; + + return true; + } +} +?> \ No newline at end of file diff --git a/inc/widgets/widgets/_coll_locale_switch.widget.php b/inc/widgets/widgets/_coll_locale_switch.widget.php index ac929f04663..59b84021a70 100644 --- a/inc/widgets/widgets/_coll_locale_switch.widget.php +++ b/inc/widgets/widgets/_coll_locale_switch.widget.php @@ -157,14 +157,23 @@ function display( $params ) if( ! empty( $linked_coll_ID ) ) { // Use linked collection: $BlogCache = & get_BlogCache(); - if( $locale_Blog = & $BlogCache->get_by_ID( $linked_coll_ID, false, false ) ) - { - $locale_switch_url = url_add_param( $locale_Blog->get( 'url' ), 'coll_locale='.urlencode( $coll_locale ) ); - } + $locale_Blog = & $BlogCache->get_by_ID( $linked_coll_ID, false, false ); } else { // Use current collection: - $locale_switch_url = url_add_param( $Blog->get( 'url' ), 'coll_locale='.urlencode( $coll_locale ) ); + $locale_Blog = $Blog; + } + if( $locale_Blog ) + { + $locale_switch_url = $locale_Blog->get( 'url' ); + if( $coll_locale != $locale_Blog->get( 'locale' ) ) + { // Append locale param only when main locale of the Collection is different than current needed: + $locale_switch_url = url_add_param( $locale_switch_url, 'coll_locale='.urlencode( $coll_locale ) ); + } + } + else + { // Skip wrong Collection: + continue; } } diff --git a/inc/widgets/widgets/_coll_logo.widget.php b/inc/widgets/widgets/_coll_logo.widget.php index dd85a9f1e0c..d248f93ae3e 100644 --- a/inc/widgets/widgets/_coll_logo.widget.php +++ b/inc/widgets/widgets/_coll_logo.widget.php @@ -140,7 +140,7 @@ function get_param_definitions( $params ) ), 'height' => array( 'label' => T_('Image height'), - 'note' => '', + 'note' => T_('Leave blank for auto.'), 'defaultvalue' => '', 'allow_empty' => true, 'size' => 4, @@ -151,7 +151,6 @@ function get_param_definitions( $params ) ), 'size_end_line' => array( 'type' => 'end_line', - 'label' => T_('Leave blank for auto.'), ), 'alt' => array( 'label' => T_('Image Alt text'), diff --git a/inc/widgets/widgets/_coll_search_form.widget.php b/inc/widgets/widgets/_coll_search_form.widget.php index 89a159c5c0e..df9f533dc49 100644 --- a/inc/widgets/widgets/_coll_search_form.widget.php +++ b/inc/widgets/widgets/_coll_search_form.widget.php @@ -85,7 +85,7 @@ function get_desc() */ function get_param_definitions( $params ) { - global $current_User, $admin_url; + global $admin_url; // Get available templates: $context = 'search_form'; $TemplateCache = & get_TemplateCache(); @@ -103,9 +103,9 @@ function get_param_definitions( $params ) 'type' => 'select', 'options' => $TemplateCache->get_code_option_array(), 'defaultvalue' => 'search_form_simple', - 'input_suffix' => ( is_logged_in() && $current_User->check_perm( 'options', 'edit' ) ? ' ' + 'input_suffix' => ( check_user_perm( 'options', 'edit' ) ? ' ' .action_icon( '', 'edit', $admin_url.'?ctrl=templates&context='.$context, NULL, NULL, NULL, - array( 'onclick' => 'return b2template_list_highlight( this )' ), + array( 'onclick' => 'return b2template_list_highlight( this )', 'target' => '_blank' ), array( 'title' => T_('Manage templates').'...' ) ) : '' ), 'class' => 'evo_template_select', ), @@ -138,6 +138,10 @@ function request_required_files() if( is_logged_in() ) { // Load JS to edit tags if it is enabled by widget setting and current User has a permission to edit them: init_tokeninput_js( 'blog' ); + + // The JS file below requires jQuery tokeninput plugin and is not bundled with evo_generic.bmin.js + // as that file is loaded before the tokeninput JS is initialized above: + require_js_defer( 'src/evo_init_widget_coll_search_form.js', 'blog' ); } } @@ -191,6 +195,17 @@ function display( $params ) $widget_Blog = & $Blog; } + if( ! $widget_Blog->get_setting( 'search_enable' ) ) + { // A search page for widget's collection is disabled: + $coll_name_link = ''.$widget_Blog->get( 'name' ).''; + $coll_setting_links = ''; + if( check_user_perm( 'blog_properties', 'edit', false, $widget_Blog->ID ) ) + { // Display a link to edit collection search setting: + $coll_setting_links = ' Change setting »'; + } + $this->display_debug_message( 'Widget "'.$this->get_name().'" is hidden because a search form is disabled for Collection "'.$coll_name_link.'".'.$coll_setting_links ); + return false; + } $TemplateCache = & get_TemplateCache(); if( ! $TemplateCache->get_by_code( $this->disp_params['template'], false, false ) ) @@ -248,77 +263,67 @@ function display( $params ) $selected_author[$key][$field] = $value; } } - ?> - - disp_params['block_body_end']; diff --git a/inc/widgets/widgets/_coll_tabbed_items.widget.php b/inc/widgets/widgets/_coll_tabbed_items.widget.php index 00aa054f93b..124fea0ee3d 100644 --- a/inc/widgets/widgets/_coll_tabbed_items.widget.php +++ b/inc/widgets/widgets/_coll_tabbed_items.widget.php @@ -31,6 +31,10 @@ class coll_tabbed_items_Widget extends param_switcher_Widget */ function __construct( $db_row = NULL ) { + // Use standard style to display debug messages on customizer for this widget + // instead of menu style that is used by default on the parent class: + $this->debug_message_style = 'standard'; + // Call parent constructor: parent::__construct( $db_row, 'core', 'coll_tabbed_items' ); } @@ -82,7 +86,7 @@ function get_desc() */ function get_param_definitions( $params ) { - global $current_User, $admin_url; + global $admin_url; // Get available templates: $context = 'content_list_master'; @@ -137,9 +141,9 @@ function get_param_definitions( $params ) 'type' => 'select', 'options' => $template_options, 'defaultvalue' => 'content_tabs', - 'input_suffix' => ( is_logged_in() && $current_User->check_perm( 'options', 'edit' ) ? ' ' + 'input_suffix' => ( check_user_perm( 'options', 'edit' ) ? ' ' .action_icon( '', 'edit', $admin_url.'?ctrl=templates&context='.$context, NULL, NULL, NULL, - array( 'onclick' => 'return b2template_list_highlight( this )' ), + array( 'onclick' => 'return b2template_list_highlight( this )', 'target' => '_blank' ), array( 'title' => T_('Manage templates').'...' ) ) : '' ), 'class' => 'evo_template_select', ), @@ -341,6 +345,32 @@ function display( $params ) $this->init_display( $params ); + if( ! isset( $Item ) || + ! $Item instanceof Item ) + { // No current Item: + $this->display_debug_message( 'Widget "'.$this->get_name().'" is hidden because this is not an Item page, so there can be no switcher params.' ); + return false; + } + + if( ! $Item->get_type_setting( 'allow_switchable' ) || + ! $Item->get_setting( 'switchable' ) ) + { // Item doesn't use switcher params: + $this->display_debug_message( 'Widget "'.$this->get_name().'" is hidden because current Item does not use switcher params.' ); + return false; + } + + if( $this->get_param( 'param_code' ) == '' ) + { // Display error when param code is not defined: + $this->display_error_message( 'Widget "'.$this->get_name().'" cannot be displayed because you did not set a param code for tab switching.' ); + return false; + } + + if( $Item->get_switchable_param( $this->get_param( 'param_code' ) ) === NULL ) + { // No default value: + $this->display_error_message( 'Widget "'.$this->get_name().'" is hidden because the param '.$this->get_param( 'param_code' ).' has not been declared/initialized in the Item.' ); + return false; + } + $blog_ID = intval( $this->disp_params['blog_ID'] ); $listBlog = ( $blog_ID ? $BlogCache->get_by_ID( $blog_ID, false ) : $Blog ); @@ -461,7 +491,10 @@ function display( $params ) { // Initialize tabs from items list: $items_tabs[] = array( 'value' => $row_Item->get( 'urltitle' ), - 'text' => $row_Item->get( 'title' ) + 'text' => $row_Item->get_title( array( + 'title_field' => 'short_title,title', + 'link_type' => 'none', + ) ), ); } // Set active tab by default on page loading: diff --git a/inc/widgets/widgets/_coll_title.widget.php b/inc/widgets/widgets/_coll_title.widget.php index 865148729bd..b44ccf5b45e 100644 --- a/inc/widgets/widgets/_coll_title.widget.php +++ b/inc/widgets/widgets/_coll_title.widget.php @@ -45,6 +45,18 @@ function __construct( $db_row = NULL ) function get_param_definitions( $params ) { $r = array_merge( array( + 'add_title_link' => array( + 'label' => T_('Add link'), + 'note' => T_('Choose when do you want the title to include a link to the page.'), + 'type' => 'radio', + 'defaultvalue' => 'auto', + 'options' => array( + array( 'auto', T_('Automatically (only when not already on the collection frontpage)') ), + array( 'always', T_('Always') ), + array( 'never', T_('Never') ) ), + 'defaultvalue' => 'auto', + 'field_lines' => true, + ), 'add_tagline' => array( 'label' => T_('Add tagline'), 'note' => T_('check to add the collection tagline after the title.'), @@ -106,16 +118,22 @@ function get_desc() */ function display( $params ) { - global $Collection, $Blog; + global $Collection, $Blog, $is_front; $this->init_display( $params ); // Collection title: echo $this->disp_params['block_start']; - $title = '' - .$Blog->dget( 'name', 'htmlbody' ) - .''; + $title = $Blog->dget( 'name', 'htmlbody' ); + + // Check whether the title should have a link or not + $linked_title = $this->disp_params['add_title_link']; + + if( $linked_title == 'always' || ($linked_title == 'auto' && !$is_front ) ) + { // Add a link to the collection in the title + $title = '' .$title .''; + } if( $this->disp_params['add_tagline'] ) { // Add a tagline after blog title $title .= ' '.$Blog->dget( 'tagline', 'htmlbody' ).''; diff --git a/inc/widgets/widgets/_content_block.widget.php b/inc/widgets/widgets/_content_block.widget.php index 7ea91259591..c9fb9af5e5d 100644 --- a/inc/widgets/widgets/_content_block.widget.php +++ b/inc/widgets/widgets/_content_block.widget.php @@ -111,16 +111,16 @@ function get_desc_for_list() */ function get_param_definitions( $params ) { - global $current_User, $admin_url; + global $admin_url; // Get available templates: $context = 'content_block'; $TemplateCache = & get_TemplateCache(); $TemplateCache->load_by_context( $context ); $template_options = $TemplateCache->get_code_option_array(); - $template_input_suffix = ( is_logged_in() && $current_User->check_perm( 'options', 'edit' ) ? ' ' + $template_input_suffix = ( check_user_perm( 'options', 'edit' ) ? ' ' .action_icon( '', 'edit', $admin_url.'?ctrl=templates&context='.$context, NULL, NULL, NULL, - array( 'onclick' => 'return b2template_list_highlight( this )' ), + array( 'onclick' => 'return b2template_list_highlight( this )', 'target' => '_blank' ), array( 'title' => T_('Manage templates').'...' ) ) : '' ); $ItemTypeCache = & get_ItemTypeCache(); @@ -267,6 +267,8 @@ function init_display( $params ) */ function display( $params ) { + global $Item; + $this->init_display( $params ); $TemplateCache = & get_TemplateCache(); @@ -278,20 +280,16 @@ function display( $params ) return false; } - echo $this->disp_params['block_start']; - - $this->disp_title(); - - echo $this->disp_params['block_body_start']; - // Get item by ID or slug: $widget_Item = & $this->get_widget_Item(); if( ! $widget_Item && $this->get_param( 'select_type' ) == 'random' ) { // If no item found ramdomly: - echo '

    '.T_('No Item is found randomly.').'

    '; + $this->display_error_message( T_('No Item is found randomly.') ); + return false; } - elseif( ! $widget_Item || $widget_Item->get_type_setting( 'usage' ) != 'content-block' ) + + if( ! $widget_Item || $widget_Item->get_type_setting( 'usage' ) != 'content-block' ) { // Item is not found by ID and slug or it is not a content block: if( $widget_Item ) { // It is not a content block: @@ -303,26 +301,70 @@ function display( $params ) $wrong_item_info = empty( $widget_item_ID ) ? '' : '#'.$widget_item_ID; $wrong_item_info .= empty( $this->disp_params['item_slug'] ) ? '' : ' '.$this->disp_params['item_slug'].''; } - echo '

    '.sprintf( T_('The referenced Item (%s) is not a Content Block.'), utf8_trim( $wrong_item_info ) ).'

    '; + $this->display_error_message( sprintf( T_('The referenced Item (%s) is not a Content Block.'), utf8_trim( $wrong_item_info ) ) ); + return false; } - elseif( ! $widget_Item->can_be_displayed() ) + + if( ! $widget_Item->can_be_displayed() ) { // Current user has no permission to view item with such status: - echo '

    '.sprintf( T_('Content block "%s" cannot be included because you have no permission.'), '#'.$widget_Item->ID.' '.$widget_Item->get( 'urltitle' ) ).'

    '; + $this->display_error_message( sprintf( T_('Content block "%s" cannot be included because you have no permission.'), '#'.$widget_Item->ID.' '.$widget_Item->get( 'urltitle' ) ) ); + return false; } - elseif( ( ( $widget_Blog = & $this->get_Blog() ) && $widget_Item->get_blog_ID() == $widget_Blog->ID ) || - ( ( $widget_Blog = & $this->get_Blog() ) && $widget_Item->get( 'creator_user_ID' ) == $widget_Blog->get( 'owner_user_ID' ) || - ( ( $info_Blog = & get_setting_Blog( 'info_blog_ID' ) ) && $widget_Item->get_blog_ID() == $info_Blog->ID ) ) ) - { // Display a content block item ONLY if at least one condition: - // - Content block Item is in same collection as this widget, - // - Content block Item has same owner as owner of this widget's collection, - // - Content block Item from collection for shared content blocks: - echo $widget_Item->get_content_block( array_merge( $params, array( 'template_code' => $this->disp_params['template'] ) ) ); + + // Display a content block Item if at least one condition is true: + $content_block_is_allowed = false; + if( isset( $Item ) && ( $Item instanceof Item ) ) + { // 1. Content block Item has same owner as owner of the current Item: + $content_block_is_allowed = $widget_Item->get( 'creator_user_ID' ) == $Item->get( 'creator_user_ID' ); } - else + $content_block_is_allowed = $content_block_is_allowed || + // 2. Content block Item is in same collection as this widget: + ( ( $widget_Blog = & $this->get_Blog() ) && $widget_Item->get_blog_ID() == $widget_Blog->ID ) || + // 3. Content block Item has same owner as owner of this widget's collection: + ( ( $widget_Blog = & $this->get_Blog() ) && $widget_Item->get( 'creator_user_ID' ) == $widget_Blog->get( 'owner_user_ID' ) ) || + // 4. Content block Item from collection for shared content blocks: + ( ( $info_Blog = & get_setting_Blog( 'info_blog_ID' ) ) && $widget_Item->get_blog_ID() == $info_Blog->ID ); + + if( ! $content_block_is_allowed ) { // Display error if the requested content block item cannot be used in this place: - echo '

    '.sprintf( T_('Content block "%s" cannot be included here. It must be in the same collection or the info pages collection; in any other case, it must have the same owner.'), '#'.$widget_Item->ID.' '.$widget_Item->get( 'urltitle' ) ).'

    '; + if( isset( $Item ) && ( $Item instanceof Item ) ) + { // For page with current Item: + $this->display_error_message( sprintf( + T_('Content block #%d %s (Coll #%d) (Owner: %s) cannot be included here. It must be in the same collection as this Widget (Coll #%d) or the info pages collection (Coll #%d)').'; '. + T_('in any other case, it must have the same owner as the current Item (Item #%d) of the page (Owner: %s) or the same owner as the current Item\'s collection (Owner: %s).'), + $widget_Item->ID, ''.$widget_Item->get( 'urltitle' ).'', // Content block #%d %s + $widget_Item->get_blog_ID(), // (Coll #%d) + get_user_identity_link( NULL, $widget_Item->get( 'creator_user_ID' ) ), // (Owner: %s) + $widget_Blog->ID, // as this Widget (Coll #%d) + ( $info_Blog = & get_setting_Blog( 'info_blog_ID' ) ) ? $info_Blog->ID : 0, // the info pages collection (Coll #%d) + $Item->ID, get_user_identity_link( NULL, $Item->get( 'creator_user_ID' ) ), // the current Item (Item #%d) (Owner: %s) + $Item->get_Blog() ? get_user_identity_link( NULL, $Item->get_Blog()->get( 'owner_user_ID' ) ) : ''.T_('No collection found').'' // the current Item\'s collection (Owner: %s) + ) ); + } + else + { // For page without current Item: + $this->display_error_message( sprintf( + T_('Content block #%d %s (Coll #%d) (Owner: %s) cannot be included here. It must be in the same collection as this Widget (Coll #%d) or the info pages collection (Coll #%d)').'. '. + T_('In any other case, it must have the same owner as the current collection (Owner: %s). Note: this page has no current Item, so we cannot check for "same owner as current Item".'), + $widget_Item->ID, ''.$widget_Item->get( 'urltitle' ).'', // Content block #%d %s + $widget_Item->get_blog_ID(), // (Coll #%d) + get_user_identity_link( NULL, $widget_Item->get( 'creator_user_ID' ) ), // (Owner: %s) + $widget_Blog->ID, // as this Widget (Coll #%d) + ( $info_Blog = & get_setting_Blog( 'info_blog_ID' ) ) ? $info_Blog->ID : 0, // the info pages collection (Coll #%d) + $widget_Blog ? get_user_identity_link( NULL, $widget_Blog->get( 'owner_user_ID' ) ) : ''.T_('No collection found').'' // the current collection (Owner: %s) + ) ); + } + return false; } + echo $this->disp_params['block_start']; + + $this->disp_title(); + + echo $this->disp_params['block_body_start']; + + echo $widget_Item->get_content_block( array_merge( $params, array( 'template_code' => $this->disp_params['template'] ) ) ); + echo $this->disp_params['block_body_end']; echo $this->disp_params['block_end']; diff --git a/inc/widgets/widgets/_display_item.widget.php b/inc/widgets/widgets/_display_item.widget.php index 62ab3ff8cb2..73c4bfc8c01 100644 --- a/inc/widgets/widgets/_display_item.widget.php +++ b/inc/widgets/widgets/_display_item.widget.php @@ -198,12 +198,6 @@ function display( $params ) return false; } - echo $this->disp_params['block_start']; - - $this->disp_title(); - - echo $this->disp_params['block_body_start']; - if( ! $widget_Item || ! in_array( $widget_Item->get_type_setting( 'usage' ), array( 'post', 'page' ) ) ) { // Item is not found by ID and slug or it is not a post or page: if( $widget_Item ) @@ -216,19 +210,36 @@ function display( $params ) $wrong_item_info = empty( $widget_item_ID ) ? '' : '#'.$widget_item_ID; $wrong_item_info .= empty( $this->disp_params['item_slug'] ) ? '' : ' '.$this->disp_params['item_slug'].''; } - echo '

    '.sprintf( T_('The referenced Item (%s) is not a Post or Standalone Page.'), utf8_trim( $wrong_item_info ) ).'

    '; + $this->display_error_message( sprintf( T_('The referenced Item (%s) is not a Post or Standalone Page.'), utf8_trim( $wrong_item_info ) ) ); + return false; } - elseif( ! $widget_Item->can_be_displayed() ) + + if( ! $widget_Item->can_be_displayed() ) { // Current user has no permission to view item with such status: - echo '

    '.sprintf( T_('Post/Page "%s" cannot be included because you have no permission.'), '#'.$widget_Item->ID.' '.$widget_Item->get( 'urltitle' ) ).'

    '; + $this->display_error_message( sprintf( T_('Post/Page "%s" cannot be included because you have no permission.'), '#'.$widget_Item->ID.' '.$widget_Item->get( 'urltitle' ) ) ); + return false; } - elseif( ( $widget_Blog = & $this->get_Blog() ) && ( - ( $widget_Item->get_blog_ID() == $widget_Blog->ID ) || - ( $widget_Item->get( 'creator_user_ID' ) == $widget_Blog->get( 'owner_user_ID' ) ) - ) ) + + $widget_Blog = & $this->get_Blog(); + if( ! $widget_Blog || ( + ( $widget_Item->get_blog_ID() != $widget_Blog->ID ) && + ( $widget_Item->get( 'creator_user_ID' ) != $widget_Blog->get( 'owner_user_ID' ) ) + ) ) { // Display an item ONLY if at least one condition: // - Item is in same collection as this widget, // - Item has same owner as owner of this widget's collection: + + // Display error if the requested content block item cannot be used in this place: + $this->display_error_message( sprintf( T_('Post/Page "%s" cannot be included here. It must be in the same collection or have the same owner.'), '#'.$widget_Item->ID.' '.$widget_Item->get( 'urltitle' ) ) ); + return false; + } + + echo $this->disp_params['block_start']; + + $this->disp_title(); + + echo $this->disp_params['block_body_start']; + global $Item; // Save current dispalying Item in temp var: @@ -264,11 +275,6 @@ function display( $params ) // Restore current dispalying Item: $Item = $orig_current_Item; - } - else - { // Display error if the requested content block item cannot be used in this place: - echo '

    '.sprintf( T_('Post/Page "%s" cannot be included here. It must be in the same collection or have the same owner.'), '#'.$widget_Item->ID.' '.$widget_Item->get( 'urltitle' ) ).'

    '; - } echo $this->disp_params['block_body_end']; diff --git a/inc/widgets/widgets/_embed_menu.widget.php b/inc/widgets/widgets/_embed_menu.widget.php index 52693ae5e53..e5775d42760 100644 --- a/inc/widgets/widgets/_embed_menu.widget.php +++ b/inc/widgets/widgets/_embed_menu.widget.php @@ -95,7 +95,7 @@ function get_desc() */ function get_param_definitions( $params ) { - global $current_User, $admin_url; + global $admin_url; $SiteMenuCache = & get_SiteMenuCache(); $SiteMenuCache->load_where( 'menu_translates_menu_ID IS NULL' ); @@ -109,7 +109,7 @@ function get_param_definitions( $params ) ), 'menu_ID' => array( 'label' => T_('Menu to display'), - 'input_suffix' => ( is_logged_in() && $current_User->check_perm( 'options', 'edit' ) ? ' '.T_('Manage Menus').' >>' : '' ), + 'input_suffix' => ( check_user_perm( 'options', 'edit' ) ? ' '.T_('Manage Menus').' >>' : '' ), 'type' => 'select_object', 'object' => $SiteMenuCache, 'defaultvalue' => '', @@ -191,7 +191,7 @@ function display( $params ) { if( $url = $SiteMenuEntry->get_url() ) { // Display a layout with menu link only if it is not restricted by some permission for current User: - echo $this->get_layout_menu_link( $url, $SiteMenuEntry->get_text(), $SiteMenuEntry->is_active() ); + echo $this->get_layout_menu_link( $url, $SiteMenuEntry->get_text(), $SiteMenuEntry->is_active(), NULL, $SiteMenuEntry->get( 'class' ) ); } } diff --git a/inc/widgets/widgets/_flag_menu_link.widget.php b/inc/widgets/widgets/_flag_menu_link.widget.php deleted file mode 100644 index 83b626833ae..00000000000 --- a/inc/widgets/widgets/_flag_menu_link.widget.php +++ /dev/null @@ -1,223 +0,0 @@ -disp_params['link_text'] ); - } - - - /** - * Get short description - */ - function get_desc() - { - return $this->get_name(); - } - - - /** - * Get definitions for editable params - * - * @see Plugin::GetDefaultSettings() - * @param local params like 'for_editing' => true - */ - function get_param_definitions( $params ) - { - $r = array_merge( array( - 'link_text' => array( - 'label' => T_('Link text'), - 'note' => T_('Text to use for the link (leave empty for default).'), - 'type' => 'text', - 'size' => 20, - 'defaultvalue' => '', - ), - 'blog_ID' => array( - 'label' => T_('Collection ID'), - 'note' => T_('Leave empty for current collection.'), - 'type' => 'integer', - 'allow_empty' => true, - 'size' => 5, - 'defaultvalue' => '', - ), - 'visibility' => array( - 'label' => T_( 'Visibility' ), - 'note' => '', - 'type' => 'radio', - 'options' => array( - array( 'always', T_( 'Always show (cacheable)') ), - array( 'access', T_( 'Only show if access is allowed (not cacheable)' ) ) ), - 'defaultvalue' => 'always', - 'field_lines' => true, - ), - 'show_badge' => array( - 'label' => T_( 'Show Badge' ), - 'note' => T_('Show a badge with the count of flagged items.'), - 'type' => 'checkbox', - 'defaultvalue' => true, - ), - 'hide_empty' => array( - 'label' => T_( 'Hide if empty' ), - 'note' => T_('Check to hide this menu if the list is empty.'), - 'type' => 'checkbox', - 'defaultvalue' => false, - ), - ), parent::get_param_definitions( $params ) ); - - if( isset( $r['allow_blockcache'] ) ) - { // Disable "allow blockcache" because this widget uses the selected items: - $r['allow_blockcache']['defaultvalue'] = false; - $r['allow_blockcache']['disabled'] = 'disabled'; - $r['allow_blockcache']['note'] = T_('This widget cannot be cached in the block cache.'); - } - - return $r; - } - - - /** - * Prepare display params - * - * @param array MUST contain at least the basic display params - */ - function init_display( $params ) - { - parent::init_display( $params ); - - // Disable "allow blockcache" because this widget uses the selected items: - $this->disp_params['allow_blockcache'] = 0; - } - - - /** - * Display the widget! - * - * @param array MUST contain at least the basic display params - */ - function display( $params ) - { - global $current_User, $disp, $Blog; - - if( ! is_logged_in() ) - { // Only logged in user can flag items: - $this->display_debug_message( 'Hidden(Not logged in)' ); - return false; - } - - $this->init_display( $params ); - - $blog_ID = intval( $this->disp_params['blog_ID'] ); - if( $blog_ID > 0 ) - { // Try to use blog from widget setting: - $BlogCache = & get_BlogCache(); - $current_Blog = & $BlogCache->get_by_ID( $blog_ID, false, false ); - } - - if( empty( $current_Blog ) ) - { // Blog is not defined in setting or it doesn't exist in DB: - global $Collection, $Blog; - // Use current blog: - $current_Blog = & $Blog; - } - - if( empty( $current_Blog ) ) - { // Don't use this widget without current collection: - $this->display_debug_message( 'Hidden(No collection)' ); - return false; - } - - if( $this->disp_params['visibility'] == 'access' && ! $current_Blog->has_access() ) - { // Don't use this widget because current user has no access to the collection: - $this->display_debug_message( 'Hidden(No access)' ); - return false; - } - - if( $this->disp_params['hide_empty'] && $current_User->get_flagged_items_count() == 0 ) - { // Hide this menu if current user has no flagged posts yet: - $this->display_debug_message( 'Hidden(No flagged posts)' ); - return false; - } - - $url = $current_Blog->get( 'flaggedurl' ); - $text = empty( $this->disp_params['link_text'] ) ? T_('Flagged Items') : $this->disp_params['link_text']; - - // Higlight current menu item only when it is linked to current collection and flagged items page is displaying currently: - $highlight_current = ( $current_Blog->ID == $Blog->ID && $disp == 'flagged' ); - - $badge = ''; - if( $this->disp_params['show_badge'] ) - { // Show badge with count of flagged items: - $flagged_items_count = $current_User->get_flagged_items_count(); - if( $flagged_items_count > 0 ) - { // If at least one flagged item: - $badge = ' '.$flagged_items_count.''; - } - } - - // Display a layout with menu link: - echo $this->get_layout_standalone_menu_link( $url, $text.$badge, $highlight_current ); - - return true; - } -} - -?> \ No newline at end of file diff --git a/inc/widgets/widgets/_generic_menu_link.widget.php b/inc/widgets/widgets/_generic_menu_link.widget.php index c1e557539dc..0c3a810482a 100644 --- a/inc/widgets/widgets/_generic_menu_link.widget.php +++ b/inc/widgets/widgets/_generic_menu_link.widget.php @@ -28,6 +28,9 @@ class generic_menu_link_Widget extends ComponentWidget // Enable additional params for classes of Link/Button: var $allow_link_css_params = true; + // Style to display debug messages on customizer mode: 'menu', 'standard' + var $debug_message_style = 'menu'; + /** * Get a layout for menu link * @@ -35,9 +38,10 @@ class generic_menu_link_Widget extends ComponentWidget * @param string Link text * @param boolean Is active menu link? * @param string Link template, possible masks: $link_url$, $link_class$, $link_text$ + * @param string Extra link class * @return string */ - function get_layout_menu_link( $link_url, $link_text, $is_active_link, $link_template = NULL ) + function get_layout_menu_link( $link_url, $link_text, $is_active_link, $link_template = NULL, $extra_link_class = '' ) { if( $link_template === NULL ) { // Use default template: @@ -63,10 +67,18 @@ function get_layout_menu_link( $link_url, $link_text, $is_active_link, $link_tem $r = $this->get_menu_link_item_start( $is_active_link ); + $link_class = $this->get_link_class( $is_active_link ); + + if( ! empty( $extra_link_class ) ) + { // Append extra CSS class: + $r = update_html_tag_attribs( $r, array( 'class' => $extra_link_class ) ); + $link_class = trim( $link_class.' '.$extra_link_class ); + } + // Get a link/button/tab from template: $r .= str_replace( array( '$link_url$', '$link_class$', '$link_text$' ), - array( $link_url, $this->get_link_class( $is_active_link ), $link_text ), + array( $link_url, $link_class, $link_text ), $link_template ); $r .= $item_end; @@ -145,29 +157,45 @@ function get_link_class( $is_active_link ) // Buttons: if( $is_active_link ) { // Class for active button: - return empty( $this->disp_params['widget_active_link_class'] ) ? $this->disp_params['button_selected_class'] : $this->disp_params['widget_active_link_class']; + $link_class = empty( $this->disp_params['widget_active_link_class'] ) ? $this->disp_params['button_selected_class'] : $this->disp_params['widget_active_link_class']; + } + else + { // Class for normal(not active) button: + $link_class = empty( $this->disp_params['widget_link_class'] ) ? $this->disp_params['button_default_class'] : $this->disp_params['widget_link_class']; } - // Class for normal(not active) button: - return empty( $this->disp_params['widget_link_class'] ) ? $this->disp_params['button_default_class'] : $this->disp_params['widget_link_class']; + break; case 'tabs': // Tabs: if( $is_active_link ) { // Class for active tab: - return trim( $this->disp_params['tab_selected_class'].( empty( $this->disp_params['widget_active_link_class'] ) ? '' : ' '.$this->disp_params['widget_active_link_class'] ) ); + $link_class = $this->disp_params['tab_selected_class'].( empty( $this->disp_params['widget_active_link_class'] ) ? '' : ' '.$this->disp_params['widget_active_link_class'] ); + } + else + { // Class for normal(not active) tab: + $link_class = $this->disp_params['tab_default_class'].( empty( $this->disp_params['widget_link_class'] ) ? '' : ' '.$this->disp_params['widget_link_class'] ); } - // Class for normal(not active) tab: - return trim( $this->disp_params['tab_default_class'].( empty( $this->disp_params['widget_link_class'] ) ? '' : ' '.$this->disp_params['widget_link_class'] ) ); + break; default: // List: if( $is_active_link ) { // Class for active link: - return trim( $this->disp_params['link_selected_class'].( empty( $this->disp_params['widget_active_link_class'] ) ? '' : ' '.$this->disp_params['widget_active_link_class'] ) ); + $link_class = $this->disp_params['link_selected_class'].( empty( $this->disp_params['widget_active_link_class'] ) ? '' : ' '.$this->disp_params['widget_active_link_class'] ); + } + else + { // Class for normal(not active) link: + $link_class = $this->disp_params['link_default_class'].( empty( $this->disp_params['widget_link_class'] ) ? '' : ' '.$this->disp_params['widget_link_class'] ); } - // Class for normal(not active) link: - return trim( $this->disp_params['link_default_class'].( empty( $this->disp_params['widget_link_class'] ) ? '' : ' '.$this->disp_params['widget_link_class'] ) ); + break; + } + + if( ! empty( $this->disp_params['link_type'] ) ) + { // Append class per link type: + $link_class .= ' evo_widget_'.$this->code.'_'.$this->disp_params['link_type']; } + + return trim( $link_class ); } @@ -238,6 +266,13 @@ function get_layout_standalone_menu_link( $link_url, $link_text, $is_active_link */ function display_debug_message( $message = NULL ) { + if( $this->debug_message_style == 'standard' ) + { // Use standard debug message without menu style: + parent::display_debug_message( $message ); + return; + } + + // Menu style: if( $this->mode == 'designer' ) { // Display message on designer mode: if( $message === NULL ) @@ -261,6 +296,13 @@ function display_debug_message( $message = NULL ) */ function display_error_message( $message = NULL ) { + if( $this->debug_message_style == 'standard' ) + { // Use standard debug message without menu style: + parent::display_error_message( $message ); + return; + } + + // Menu style: global $current_User, $Blog; if( isset( $this->BlockCache ) ) @@ -278,7 +320,7 @@ function display_error_message( $message = NULL ) $message .= '('.$this->disp_params['link_type'].')'; } } - echo $this->get_layout_standalone_menu_link( '#', ''.$message.'', false ); + echo $this->get_layout_standalone_menu_link( '#', get_rendering_error( $message, 'span' ), false ); } } } \ No newline at end of file diff --git a/inc/widgets/widgets/_image.widget.php b/inc/widgets/widgets/_image.widget.php index 16db75935f1..8797c40e09f 100644 --- a/inc/widgets/widgets/_image.widget.php +++ b/inc/widgets/widgets/_image.widget.php @@ -122,14 +122,13 @@ function get_param_definitions( $params ) 'size_begin_line' => array( 'type' => 'begin_line', 'label' => T_('Image size'), + 'note' => T_('Leave blank for auto.'), ), 'width' => array( - 'label' => T_('Image width'), 'note' => '', 'defaultvalue' => '', 'allow_empty' => true, 'size' => 4, - 'hide_label' => true, 'valid_pattern' => array( 'pattern' => '~^(\d+(px|%)?)?$~i', 'error' => sprintf( T_('Invalid image size, it must be specified in px or %%.') ) ), @@ -139,19 +138,45 @@ function get_param_definitions( $params ) 'type' => 'string', ), 'height' => array( - 'label' => T_('Image height'), - 'note' => '', + 'note' => T_('Leave blank for auto.'), 'defaultvalue' => '', 'allow_empty' => true, 'size' => 4, - 'hide_label' => true, 'valid_pattern' => array( 'pattern' => '~^(\d+(px|%)?)?$~i', 'error' => sprintf( T_('Invalid image size, it must be specified in px or %%.') ) ), ), 'size_end_line' => array( 'type' => 'end_line', - 'label' => T_('Leave blank for auto.'), + ), + 'max_size_begin_line' => array( + 'type' => 'begin_line', + 'label' => T_('Max size'), + ), + 'max_width' => array( + 'note' => '', + 'defaultvalue' => '', + 'allow_empty' => true, + 'size' => 4, + 'valid_pattern' => array( + 'pattern' => '~^(\d+(px|%)?)?$~i', + 'error' => sprintf( T_('Invalid max size, it must be specified in px or %%.') ) ), + ), + 'max_size_separator' => array( + 'label' => ' x ', + 'type' => 'string', + ), + 'max_height' => array( + 'note' => T_('Leave blank for auto.'), + 'defaultvalue' => '', + 'allow_empty' => true, + 'size' => 4, + 'valid_pattern' => array( + 'pattern' => '~^(\d+(px|%)?)?$~i', + 'error' => sprintf( T_('Invalid max size, it must be specified in px or %%.') ) ), + ), + 'max_size_end_line' => array( + 'type' => 'end_line', ), 'alt' => array( 'label' => T_('Image Alt text'), @@ -243,9 +268,18 @@ function display( $params ) ); // Initialize image attributes: + // Image width: $image_attrs['style'] = 'width:'.( empty( $this->disp_params['width'] ) ? 'auto' : format_to_output( $this->disp_params['width'], 'htmlattr' ) ).';'; // Image height: $image_attrs['style'] .= 'height:'.( empty( $this->disp_params['height'] ) ? 'auto' : format_to_output( $this->disp_params['height'], 'htmlattr' ) ).';'; + if( ! empty( $this->disp_params['max_width'] ) ) + { // Max width: + $image_attrs['style'] .= 'max-width:'.format_to_output( $this->disp_params['max_width'], 'htmlattr' ).';'; + } + if( ! empty( $this->disp_params['max_height'] ) ) + { // Max height: + $image_attrs['style'] .= 'max-height:'.format_to_output( $this->disp_params['max_height'], 'htmlattr' ).';'; + } // If no unit is specified in a size, consider the unit to be px: $image_attrs['style'] = preg_replace( '/(\d+);/', '$1px;', $image_attrs['style'] ); diff --git a/inc/widgets/widgets/_item_about_author.widget.php b/inc/widgets/widgets/_item_about_author.widget.php index 7a161981656..f605320389b 100644 --- a/inc/widgets/widgets/_item_about_author.widget.php +++ b/inc/widgets/widgets/_item_about_author.widget.php @@ -94,6 +94,15 @@ function get_desc() */ function get_param_definitions( $params ) { + global $admin_url; + + // Get available templates: + $context = 'item_details'; + $TemplateCache = & get_TemplateCache(); + $TemplateCache->load_by_context( $context ); + + $template_options = array( NULL => T_('No template / use settings below').':' ) + $TemplateCache->get_code_option_array(); + // Load Userfield class and all fields: load_class( 'users/model/_userfield.class.php', 'Userfield' ); $UserFieldCache = & get_UserFieldCache(); @@ -120,6 +129,17 @@ function get_param_definitions( $params ) 'note' => T_( 'This is the title to display' ), 'defaultvalue' => '', ), + 'template' => array( + 'label' => T_('Template'), + 'type' => 'select', + 'options' => $template_options, + 'defaultvalue' => NULL, + 'input_suffix' => ( check_user_perm( 'options', 'edit' ) ? ' ' + .action_icon( '', 'edit', $admin_url.'?ctrl=templates&context='.$context, NULL, NULL, NULL, + array( 'onclick' => 'return b2template_list_highlight( this )', 'target' => '_blank' ), + array( 'title' => T_('Manage templates').'...' ) ) : '' ), + 'class' => 'evo_template_select', + ), 'thumb_size' => array( 'label' => T_('Display user image'), 'note' => T_('Cropping and sizing of thumbnails'), @@ -181,63 +201,97 @@ function display( $params ) $this->init_display( $params ); - if( empty( $this->disp_params['user_field'] ) ) - { // Not defined user field in the widget settings: - $this->display_error_message( 'Widget "'.$this->get_name().'" is hidden because there is no defined widget param "user_field".' ); - return false; - } + if( empty( $this->disp_params['template'] ) ) + { + if( empty( $this->disp_params['user_field'] ) ) + { // Not defined user field in the widget settings: + $this->display_error_message( 'Widget "'.$this->get_name().'" is hidden because there is no defined widget param "user_field".' ); + return false; + } - // Load user fields - $creator_User = & $Item->get_creator_User(); - $creator_User->userfields_load(); - if( empty( $creator_User->userfields_by_type[ $this->disp_params['user_field'] ] ) ) - { // No user field by ID for current author: - $this->display_debug_message( 'Widget "'.$this->get_name().'" is hidden because there is no defined widget param "user_field".' ); - return false; - } + // Load user fields + $creator_User = & $Item->get_creator_User(); + $creator_User->userfields_load(); + if( empty( $creator_User->userfields_by_type[ $this->disp_params['user_field'] ] ) ) + { // No user field by ID for current author: + $this->display_debug_message( 'Widget "'.$this->get_name().'" is hidden because there is no defined widget param "user_field".' ); + return false; + } - $user_info = ''; + $user_info = ''; - $user_info .= '
    '; - $user_info .= $creator_User->userfield_value_by_ID( $this->disp_params['user_field'] ); - $user_info .= '
    '; + $user_info .= '
    '; + $user_info .= $creator_User->userfield_value_by_ID( $this->disp_params['user_field'] ); + $user_info .= '
    '; - if( empty( $user_info ) ) - { // No user info: - $this->display_debug_message( 'Widget "'.$this->get_name().'" is hidden because there is no user info.' ); - return false; - } + if( empty( $user_info ) ) + { // No user info: + $this->display_debug_message( 'Widget "'.$this->get_name().'" is hidden because there is no user info.' ); + return false; + } - // Display user info only when it is defined for current author - echo add_tag_class( $this->disp_params['block_start'], 'clearfix' ); - $this->disp_title(); - echo $this->disp_params['block_body_start']; + // Display user info only when it is defined for current author + echo add_tag_class( $this->disp_params['block_start'], 'clearfix' ); + $this->disp_title(); + echo $this->disp_params['block_body_start']; - if( ! empty( $this->disp_params['thumb_size'] ) ) - { - echo '
    '; + if( ! empty( $this->disp_params['thumb_size'] ) ) + { + echo '
    '; - $user_url = $this->disp_params['link_profile'] ? $creator_User->get_userpage_url() : ''; + $user_url = $this->disp_params['link_profile'] ? $creator_User->get_userpage_url() : ''; - if( ! empty( $user_url ) ) - { - echo ''; + if( ! empty( $user_url ) ) + { + echo ''; + } + + echo $creator_User->get_avatar_imgtag( $this->disp_params['thumb_size'] ); + if( ! empty( $user_url ) ) + { + echo ''; + } + + echo '
    '; } + echo $user_info; - echo $creator_User->get_avatar_imgtag( $this->disp_params['thumb_size'] ); - if( ! empty( $user_url ) ) + echo $this->disp_params['block_body_end']; + echo $this->disp_params['block_end']; + + return true; + } + else + { + $TemplateCache = & get_TemplateCache(); + if( ! $TemplateCache->get_by_code( $this->disp_params['template'], false, false ) ) { - echo ''; + $this->display_error_message( sprintf( 'Template not found: %s', ''.$this->disp_params['template'].'' ) ); + return false; } - echo '
    '; - } - echo $user_info; + $template = $this->disp_params['template']; + $item_author_User = & $Item->get_creator_User(); + $rendered_template = render_template_code( $template, $this->disp_params, array( 'User' => $item_author_User ) ); + + if( ! empty( $rendered_template ) ) + { + // Display user info only when it is defined for current author + echo $this->disp_params['block_start']; + $this->disp_title(); + echo $this->disp_params['block_body_start']; + + echo $rendered_template; - echo $this->disp_params['block_body_end']; - echo $this->disp_params['block_end']; + echo $this->disp_params['block_body_end']; + echo $this->disp_params['block_end']; - return true; + return true; + } + + $this->display_debug_message(); + return false; + } } @@ -264,8 +318,9 @@ function get_cache_keys() 'set_coll_ID' => $Blog->ID, // Have the settings of the blog changed ? (ex: new skin) 'user_ID' => $creator_user_ID, // Has the creator User changed? 'item_ID' => ( empty( $Item->ID ) ? 0 : $Item->ID ), // Has the Item page changed? + 'template_code' => $this->get_param( 'template' ), // Has the Template changed? ); } } -?> \ No newline at end of file +?> diff --git a/inc/widgets/widgets/_item_attachments.widget.php b/inc/widgets/widgets/_item_attachments.widget.php index bc054dc603d..de63ad4d47e 100644 --- a/inc/widgets/widgets/_item_attachments.widget.php +++ b/inc/widgets/widgets/_item_attachments.widget.php @@ -92,42 +92,32 @@ function get_desc() */ function get_param_definitions( $params ) { + global $admin_url; + + // Get available templates: + $context = 'item_details'; + $TemplateCache = & get_TemplateCache(); + $TemplateCache->load_by_context( $context ); + $r = array_merge( array( 'title' => array( - 'label' => T_( 'Title' ), - 'size' => 40, - 'note' => T_( 'This is the title to display' ), - 'defaultvalue' => '', - ), - 'disp_download_icon' => array( - 'type' => 'checkbox', - 'label' => T_('Display download icon'), - 'defaultvalue' => 1, - 'note' => '', - ), - 'link_text' => array( - 'label' => T_('Link'), - 'note' => '', - 'type' => 'radio', - 'field_lines' => true, - 'options' => array( - array( 'filename', T_('Always display Filename') ), - array( 'title', T_('Display Title if available') ) ), - 'defaultvalue' => 'title', - ), - 'disp_file_size' => array( - 'type' => 'checkbox', - 'label' => T_('Display file size'), - 'defaultvalue' => 1, - 'note' => '', - ), - 'disp_file_desc' => array( - 'type' => 'checkbox', - 'label' => T_('Add descriptions'), - 'defaultvalue' => 1, - 'note' => T_('Display description if available.'), - ), - ), parent::get_param_definitions( $params ) ); + 'label' => T_('Title'), + 'size' => 40, + 'note' => T_('This is the title to display'), + 'defaultvalue' => T_('Attachments').':', + ), + 'template' => array( + 'label' => T_('Template'), + 'type' => 'select', + 'options' => $TemplateCache->get_code_option_array(), + 'defaultvalue' => 'item_details_files_list', + 'input_suffix' => ( check_user_perm( 'options', 'edit' ) ? ' ' + .action_icon( '', 'edit', $admin_url.'?ctrl=templates&context='.$context, NULL, NULL, NULL, + array( 'onclick' => 'return b2template_list_highlight( this )', 'target' => '_blank' ), + array( 'title' => T_('Manage templates').'...' ) ) : '' ), + 'class' => 'evo_template_select', + ), + ), parent::get_param_definitions( $params ) ); return $r; } @@ -150,20 +140,25 @@ function display( $params ) $this->init_display( $params ); + $TemplateCache = & get_TemplateCache(); + if( ! $TemplateCache->get_by_code( $this->disp_params['template'], false, false ) ) + { // No template: + $this->display_error_message( sprintf( 'Template not found: %s', ''.$this->disp_params['template'].'' ) ); + return false; + } + $this->disp_params = array_merge( array( 'widget_item_attachments_params' => array(), + 'image_attachment' => true, ), $this->disp_params ); - // Get attachments/files that are linked to the current item: - $item_files = $Item->get_files( array_merge( $this->disp_params['widget_item_attachments_params'], array( - 'display_download_icon' => $this->disp_params['disp_download_icon'], - 'file_link_text' => $this->disp_params['link_text'], - 'display_file_size' => $this->disp_params['disp_file_size'], - 'display_file_desc' => $this->disp_params['disp_file_desc'], - ) ) ); + $item_files = render_template_code( $this->disp_params['template'], $this->disp_params ); if( empty( $item_files ) ) { // Don't display this widget when Item has no attachments: + $this->disp_params = array_merge( array( + 'hide_header_title' => true, + ), $this->disp_params ); $this->display_debug_message( 'Widget "'.$this->get_name().'" is hidden because Item has no attachments.' ); return false; } @@ -194,8 +189,9 @@ function get_cache_keys() return array( 'wi_ID' => $this->ID, // Have the widget settings changed ? 'set_coll_ID' => $Blog->ID, // Have the settings of the blog changed ? (ex: new skin) - 'cont_coll_ID' => empty( $this->disp_params['blog_ID'] ) ? $Blog->ID : $this->disp_params['blog_ID'], // Has the content of the displayed blog changed ? + 'cont_coll_ID' => $Blog->ID, // Has the content of the displayed blog changed ? 'item_ID' => ( empty( $Item->ID ) ? 0 : $Item->ID ), // Has the Item page changed? + 'template_code' => $this->get_param( 'template' ), // Has the Template changed? ); } } diff --git a/inc/widgets/widgets/_item_checklist_lines.widget.php b/inc/widgets/widgets/_item_checklist_lines.widget.php new file mode 100644 index 00000000000..4c21d177e0f --- /dev/null +++ b/inc/widgets/widgets/_item_checklist_lines.widget.php @@ -0,0 +1,278 @@ + true + */ + function get_param_definitions( $params ) + { + $r = array_merge( array( + 'title' => array( + 'label' => T_( 'Title' ), + 'size' => 40, + 'note' => T_( 'This is the title to display' ), + 'defaultvalue' => 'Checklist', + ), + 'allow_edit' => array( + 'label' => T_( 'Allow editing' ), + 'type' => 'checkbox', + 'note' => T_( 'Check to enable AJAX editing of checklist lines if current user has permission.' ), + 'defaultvalue' => 1, + ), + ), parent::get_param_definitions( $params ) ); + + if( isset( $r['allow_blockcache'] ) ) + { // Disable "allow blockcache" because this widget uses the selected items: + $r['allow_blockcache']['defaultvalue'] = false; + $r['allow_blockcache']['disabled'] = 'disabled'; + $r['allow_blockcache']['note'] = T_('This widget cannot be cached in the block cache.'); + } + + return $r; + } + + + /** + * Request all required css and js files for this widget + */ + function request_required_files() + { + global $Item; + + if( ! empty( $Item ) && $this->get_param( 'allow_edit' ) && $Item->can_meta_comment() ) + { // Load JS to edit checklist lines if it is enabled by widget setting and current User has a permission to edit them: + require_js_defer( '#jquery#', 'blog' ); + require_js_defer( '#jqueryUI#', 'blog' ); + } + } + + + /** + * Prepare display params + * + * @param array MUST contain at least the basic display params + */ + function init_display( $params ) + { + global $preview; + + parent::init_display( $params ); + + if( $preview ) + { // Disable block caching for this widget when item is previewed currently: + $this->disp_params['allow_blockcache'] = 0; + } + } + + + /** + * Display the widget! + * + * @param array MUST contain at least the basic display params + */ + function display( $params ) + { + $this->init_display( $params ); + + if( ! empty( $params['Item'] ) ) + { // Used Item provided by params: + $Item = $params['Item']; + } + else + { // use global Item: + global $Item; + } + + if( empty( $Item ) ) + { // Don't display this widget when no Item object + $this->display_error_message( 'Widget "'.$this->get_name().'" is hidden because there is no Item object.' ); + return false; + } + + // Check permission to add/edit/delete checklist lines: + $can_update = $this->get_param( 'allow_edit' ) && $Item->can_meta_comment(); + + // Get existing checklist lines: + $checklist_lines = $Item->get_checklist_lines(); + + if( ! $Item->can_see_meta_comments() || // Current User has no perm to view checklist lines + ( empty( $checklist_lines ) && ! $can_update ) ) // No + { // Nothing to display because current User cannot see this OR the Item has no checklist lines: + $this->display_debug_message( 'Widget "'.$this->get_name().'" is hidden because you cannot see this or current Item has no checklist lines.' ); + return false; + } + + echo $this->disp_params['block_start']; + $this->disp_title(); + echo $this->disp_params['block_body_start']; + + echo '
    '; + $Form = new Form(); + $Form->switch_layout( 'linespan' ); + + if( $can_update ) + { + $Form->output = false; + + $js_config = array( + 'item_ID' => $Item->ID, + 'checklist_line_template' => '
    + '. + action_icon( T_('Delete'), 'delete', '#', NULL, NULL, NULL, array( 'class' => 'checklist_line_delete', 'style' => 'visibility:hidden;' ) ). + '
    ', + 'checklist_line_input_template' => $Form->textarea_input( '$checklist_line_ID$', '$checklist_line_label$', 1, '', array( + 'class' => 'checklist_line_input', + 'placeholder' => T_('Add an item'), + 'hide_label' => true, + 'maxlength' => 10000 + ) ), + 'crumb_checklist_line' => get_crumb( 'collections_checklist_line' ), + 'button_label_add' => T_('Add'), + 'button_label_add_an_item' => T_('Add an item'), + ); + + expose_var_to_js( 'evo_init_checklist_lines_config', evo_json_encode( $js_config ) ); + + $Form->output = true; + } + + echo '
    '; + + // Extra drop area for checklist lines to first position: + echo '
    '; + + foreach( $checklist_lines as $line ) + { + echo '
    '; + echo ''; + if( $can_update ) + { + echo action_icon( T_('Delete'), 'delete', '#', NULL, NULL, NULL, array( 'class' => 'checklist_line_delete', 'style' => 'visibility:hidden;' ) ); + } + echo '
    '; + } + + echo '
    '; + + if( $can_update ) + { + $Form->switch_template_parts( array( + 'fieldstart' => '', + 'fieldend' => '', + )); + $Form->textarea_input( 'checklist_input_'.$this->ID, NULL, 1, '', array( + 'class' => 'add_checklist_line_input checklist_line_input', + 'placeholder' => T_('Add an item'), + 'hide_label' => true, + 'maxlength' => 10000, + 'style' => 'display:none', + ) ); + + echo ''; + echo ''; + } + + echo '
    '; + + echo $this->disp_params['block_body_end']; + echo $this->disp_params['block_end']; + + return true; + } +} +?> diff --git a/inc/widgets/widgets/_item_comment_form.widget.php b/inc/widgets/widgets/_item_comment_form.widget.php index 67b578e6f3d..45925a2f226 100644 --- a/inc/widgets/widgets/_item_comment_form.widget.php +++ b/inc/widgets/widgets/_item_comment_form.widget.php @@ -585,7 +585,7 @@ function validateCommentForm(form)
    '; // JS code to don't hide popup on click to checkbox: - $text_renderers .= ''; + expose_var_to_js( 'evo_commentform_renderers__click', true ); } if( $Blog->get_setting( 'allow_html_comment' ) ) @@ -704,7 +704,7 @@ function validateCommentForm(form) if( $Item->can_attach() ) { // Don't display "/Add file" on the preview button if JS is enabled: - echo ''; + expose_var_to_js( 'evo_comment_form_preview_button_config', evo_json_encode( array( 'button_value' => T_('Preview') ) ) ); } $Plugins->trigger_event( 'DisplayCommentFormButton', array( 'Form' => & $Form, 'Item' => & $Item ) ); diff --git a/inc/widgets/widgets/_item_content.widget.php b/inc/widgets/widgets/_item_content.widget.php index c3a04f89203..0a28814ffab 100644 --- a/inc/widgets/widgets/_item_content.widget.php +++ b/inc/widgets/widgets/_item_content.widget.php @@ -100,7 +100,12 @@ function get_param_definitions( $params ) 'size' => 40, 'note' => T_( 'This is the title to display' ), 'defaultvalue' => '', - ) + ), + 'info' => array( + 'type' => 'info', + 'label' => T_('Info'), + 'info' => sprintf( T_('This widget will use the templates associated with the current Item Type.'), 'href="'.get_admin_url( 'ctrl=itemtypes&blog='.$this->get_coll_ID() ).'"' ), + ), ), parent::get_param_definitions( $params ) ); if( isset( $r['allow_blockcache'] ) ) diff --git a/inc/widgets/widgets/_item_fields_compare.widget.php b/inc/widgets/widgets/_item_fields_compare.widget.php index 6fce553c9ba..cdff7e07083 100644 --- a/inc/widgets/widgets/_item_fields_compare.widget.php +++ b/inc/widgets/widgets/_item_fields_compare.widget.php @@ -102,7 +102,7 @@ function get_param_definitions( $params ) 'param' => sprintf( T_('As specified by "%s" URL param'), 'items=' ), 'list' => T_('Specific IDs listed below'), ), - 'defaultvalue' => 'param', + 'defaultvalue' => 'all', ), 'items' => array( 'label' => T_('Specific Item IDs'), @@ -319,13 +319,19 @@ function display( $params ) // Get IDs of items which should be compared: $items = $this->get_items_IDs(); + if( empty( $items ) ) + { // No items to compare: + $this->display_debug_message( 'Widget "'.$this->get_name().'" is hidden because no Items to compare.' ); + return false; + } + // Get custom fields with compared data: $custom_fields = $this->get_custom_fields( $items ); if( empty( $custom_fields ) ) - { // Nothing to compare: + { // No fields to compare: $this->display_debug_message( 'Widget "'.$this->get_name().'" is hidden because no fields to compare.' ); - return; + return false; } // Check if headers for item statuses should be displayed diff --git a/inc/widgets/widgets/_item_info_line.widget.php b/inc/widgets/widgets/_item_info_line.widget.php index b57b9fba950..19a36894d7e 100644 --- a/inc/widgets/widgets/_item_info_line.widget.php +++ b/inc/widgets/widgets/_item_info_line.widget.php @@ -92,7 +92,7 @@ function get_desc() */ function get_param_definitions( $params ) { - global $current_User, $admin_url; + global $admin_url; // Get available templates: $context = 'item_details'; @@ -111,9 +111,9 @@ function get_param_definitions( $params ) 'type' => 'select', 'options' => $TemplateCache->get_code_option_array(), 'defaultvalue' => 'item_details_infoline_standard', - 'input_suffix' => ( is_logged_in() && $current_User->check_perm( 'options', 'edit' ) ? ' ' + 'input_suffix' => ( check_user_perm( 'options', 'edit' ) ? ' ' .action_icon( '', 'edit', $admin_url.'?ctrl=templates&context='.$context, NULL, NULL, NULL, - array( 'onclick' => 'return b2template_list_highlight( this )' ), + array( 'onclick' => 'return b2template_list_highlight( this )', 'target' => '_blank' ), array( 'title' => T_('Manage templates').'...' ) ) : '' ), 'class' => 'evo_template_select', ), diff --git a/inc/widgets/widgets/_item_link.widget.php b/inc/widgets/widgets/_item_link.widget.php index c6ae2f23b9f..f2bca03b322 100644 --- a/inc/widgets/widgets/_item_link.widget.php +++ b/inc/widgets/widgets/_item_link.widget.php @@ -203,7 +203,7 @@ function display( $params ) */ function get_cache_keys() { - global $Collection, $Blog, $current_User, $Item; + global $Collection, $Blog, $Item; return array( 'wi_ID' => $this->ID, // Have the widget settings changed ? diff --git a/inc/widgets/widgets/_item_seen_by.widget.php b/inc/widgets/widgets/_item_seen_by.widget.php index bf39207433d..059e6822dd8 100644 --- a/inc/widgets/widgets/_item_seen_by.widget.php +++ b/inc/widgets/widgets/_item_seen_by.widget.php @@ -138,7 +138,7 @@ function get_param_definitions( $params ) */ function display( $params ) { - global $Collection, $Blog, $Item, $current_User, $DB; + global $Collection, $Blog, $Item, $DB; $this->init_display( $params ); @@ -154,7 +154,7 @@ function display( $params ) return false; } - if( ! is_logged_in() || ! $current_User->check_perm( 'item_post!CURSTATUS', 'edit', false, $Item ) ) + if( ! check_user_perm( 'item_post!CURSTATUS', 'edit', false, $Item ) ) { // Don't display this widget if user is NOT logged in OR user has no permission to edit this Item: $this->display_debug_message( 'Widget "'.$this->get_name().'" is hidden because there is no user permission.' ); return false; diff --git a/inc/widgets/widgets/_item_small_print.widget.php b/inc/widgets/widgets/_item_small_print.widget.php index 17e650f143f..fbc88c44654 100644 --- a/inc/widgets/widgets/_item_small_print.widget.php +++ b/inc/widgets/widgets/_item_small_print.widget.php @@ -96,7 +96,7 @@ function get_desc() */ function get_param_definitions( $params ) { - global $current_User, $admin_url; + global $admin_url; // Get available templates: $context = 'item_details'; @@ -115,9 +115,9 @@ function get_param_definitions( $params ) 'type' => 'select', 'options' => $TemplateCache->get_code_option_array(), 'defaultvalue' => 'item_details_smallprint_standard', - 'input_suffix' => ( is_logged_in() && $current_User->check_perm( 'options', 'edit' ) ? ' ' + 'input_suffix' => ( check_user_perm( 'options', 'edit' ) ? ' ' .action_icon( '', 'edit', $admin_url.'?ctrl=templates&context='.$context, NULL, NULL, NULL, - array( 'onclick' => 'return b2template_list_highlight( this )' ), + array( 'onclick' => 'return b2template_list_highlight( this )', 'target' => '_blank' ), array( 'title' => T_('Manage templates').'...' ) ) : '' ), 'class' => 'evo_template_select', ), diff --git a/inc/widgets/widgets/_item_tags.widget.php b/inc/widgets/widgets/_item_tags.widget.php index 47fe13e917b..f952aa8d077 100644 --- a/inc/widgets/widgets/_item_tags.widget.php +++ b/inc/widgets/widgets/_item_tags.widget.php @@ -124,13 +124,13 @@ function get_param_definitions( $params ) */ function request_required_files() { - global $Item, $current_User; + global $Item; - if( ! empty( $Item ) && $this->get_param( 'allow_edit' ) && is_logged_in() && $current_User->check_perm( 'item_post!CURSTATUS', 'edit', false, $Item ) ) + if( ! empty( $Item ) && $this->get_param( 'allow_edit' ) && check_user_perm( 'item_post!CURSTATUS', 'edit', false, $Item ) ) { // Load JS to edit tags if it is enabled by widget setting and current User has a permission to edit them: init_tokeninput_js( 'blog' ); - require_js( '#jquery#', 'blog' ); - require_js( 'jquery/jquery.cookie.min.js', 'blog' ); + require_js_defer( '#jquery#', 'blog' ); + require_js_defer( 'ext:jquery/cookie/jquery.cookie.min.js', 'blog' ); } } @@ -160,7 +160,7 @@ function init_display( $params ) */ function display( $params ) { - global $Item, $current_User; + global $Item; $this->init_display( $params ); @@ -216,7 +216,7 @@ function display( $params ) $quick_tag_buttons = $this->disp_params['widget_item_tags_before_quicklist']; foreach( $quick_item_tags as $item_tag ) { - $quick_tag_buttons .= ''; + $quick_tag_buttons .= ''; } $quick_tag_buttons .= $this->disp_params['widget_item_tags_after_quicklist'];; @@ -250,29 +250,19 @@ function display( $params ) $this->disp_params['widget_item_tags_after'] .= ' '.action_icon( T_('Edit tags'), 'edit', $Item->get_edit_url( array( 'force_backoffice_editing' => true ) ).'#itemform_adv_props', NULL, NULL, NULL, array( 'id' => 'evo_widget_item_tags_edit_icon_'.$this->ID ) ) - .'' - // JS to activate an edit tags form: - .''; + .''; + + // JS to activate an edit tags form: + $js_config = array( + 'input_ID' => 'item_tags_'.$this->ID, + 'widget_ID' => $this->ID + ); + expose_var_to_js( 'item_tags_widget_'.$this->ID, $js_config, 'evo_item_tags_widget_config' ); } if( $this->get_param( 'allow_edit' ) && - is_logged_in() && - $current_User->check_perm( 'admin', 'restricted' ) && - $current_User->check_perm( 'options', 'edit' ) ) + check_user_perm( 'admin', 'restricted' ) && + check_user_perm( 'options', 'edit' ) ) { // Use different style for edit mode, make tag icon as link to edit item tag in back-office: global $admin_url, $ReqURL; $tags_params['before_tag'] = ''.action_icon( T_('Edit tag'), 'tag', $admin_url.'?ctrl=itemtags&action=edit&tag_ID=$tag_ID$&return_to='.rawurlencode( $ReqURL ) ); diff --git a/inc/widgets/widgets/_item_vote.widget.php b/inc/widgets/widgets/_item_vote.widget.php index cfee11f9073..c2a0fb06ae1 100644 --- a/inc/widgets/widgets/_item_vote.widget.php +++ b/inc/widgets/widgets/_item_vote.widget.php @@ -128,7 +128,7 @@ function get_param_definitions( $params ) */ function display( $params ) { - global $Collection, $Blog, $current_User, $DB; + global $Collection, $Blog, $DB; $this->init_display( $params ); diff --git a/inc/widgets/widgets/_item_workflow.widget.php b/inc/widgets/widgets/_item_workflow.widget.php index fd947872505..08f886c1f1e 100644 --- a/inc/widgets/widgets/_item_workflow.widget.php +++ b/inc/widgets/widgets/_item_workflow.widget.php @@ -147,7 +147,7 @@ function init_display( $params ) */ function display( $params ) { - global $Item, $current_User; + global $Item; global $ReqURL; if( empty( $Item ) ) @@ -162,16 +162,15 @@ function display( $params ) return false; } - if( ! is_logged_in() || ! $current_User->check_perm( 'blog_can_be_assignee', 'edit', false, $Item->get_blog_ID() ) ) + if( ! check_user_perm( 'blog_can_be_assignee', 'edit', false, $Item->get_blog_ID() ) ) { // Current User has no permission to be assigned for tasks of the Item's Collection: $this->display_debug_message( 'Widget "'.$this->get_name().'" is hidden because you don\'t have a permission to be assigned for tasks of the Item\'s Collection.' ); return false; } $allow_edit = $this->disp_params['allow_edit'] && - is_logged_in() && - $current_User->check_perm( 'admin', 'restricted' ) && - $current_User->check_perm( 'options', 'edit' ); + check_user_perm( 'admin', 'restricted' ) && + check_user_perm( 'options', 'edit' ); $this->init_display( $params ); @@ -268,15 +267,7 @@ function display( $params ) echo '
    '; $Form->end_form(); - ?> - - ID ); } echo $this->disp_params['block_body_end']; diff --git a/inc/widgets/widgets/_msg_menu_link.widget.php b/inc/widgets/widgets/_msg_menu_link.widget.php deleted file mode 100644 index a10f70fdd03..00000000000 --- a/inc/widgets/widgets/_msg_menu_link.widget.php +++ /dev/null @@ -1,319 +0,0 @@ -link_types = array( - 'messages' => T_('Private messages'), - 'contacts' => T_('Messaging contacts'), - ); - } - - - /** - * Get help URL - * - * @return string URL - */ - function get_help_url() - { - return get_manual_url( 'messaging-menu-link-widget' ); - } - - - /** - * Get name of widget - */ - function get_name() - { - return T_('Messaging Menu link or button'); - } - - - /** - * Get a very short desc. Used in the widget list. - */ - function get_short_desc() - { - $this->load_param_array(); - - if( !empty($this->param_array['link_type']) ) - { // Messaging or Contacts - return sprintf( T_('Link to: %s'), $this->link_types[ $this->param_array['link_type'] ] ); - } - - return $this->get_name(); - } - - - /** - * Get short description - */ - function get_desc() - { - return T_('Messages or Contacts menu entry/link'); - } - - - /** - * Get definitions for editable params - * - * @see Plugin::GetDefaultSettings() - * @param local params like 'for_editing' => true - */ - function get_param_definitions( $params ) - { - global $admin_url; - - // Try to get collection that is used for messages on this site: - $msg_Blog = & get_setting_Blog( 'msg_blog_ID' ); - - $default_link_type = 'messages'; - - $r = array_merge( array( - 'link_type' => array( - 'label' => T_( 'Link Type' ), - 'note' => T_('What do you want to link to?'), - 'type' => 'select', - 'options' => $this->link_types, - 'defaultvalue' => $default_link_type, - 'onchange' => ' - var curr_link_type = this.value; - var show_badge = jQuery("[id$=\'_set_show_badge\']"); - if( curr_link_type == "messages" ) - { - show_badge.removeAttr(\'disabled\'); - show_badge.attr( \'checked\', \'checked\' ); - } - else - { - show_badge.attr( \'disabled\', \'disabled\' ); - show_badge.removeAttr(\'checked\'); - };' - ), - 'link_text' => array( - 'label' => T_( 'Link text' ), - 'note' => T_('Text to use for the link (leave empty for default).'), - 'type' => 'text', - 'size' => 20, - 'defaultvalue' => '', - ), - 'blog_ID' => array( - 'label' => T_('Collection ID'), - 'note' => T_('Leave empty for current collection.') - .( $msg_Blog ? ' '.sprintf( T_('The site is configured to always use collection %s for profiles/messaging functions.'), - 'href="'.$admin_url.'?ctrl=collections&tab=site_settings"', - ''.$msg_Blog->get( 'name' ).'' ).'' : '' ), - 'type' => 'integer', - 'allow_empty' => true, - 'size' => 5, - 'defaultvalue' => '', - 'disabled' => $msg_Blog ? 'disabled' : false, - ), - 'visibility' => array( - 'label' => T_( 'Visibility' ), - 'note' => '', - 'type' => 'radio', - 'options' => array( - array( 'always', T_( 'Always show (cacheable)') ), - array( 'access', T_( 'Only show if access is allowed (not cacheable)' ) ) ), - 'defaultvalue' => 'always', - 'field_lines' => true, - ), - 'show_to' => array( - 'label' => T_( 'Show to' ), - 'note' => '', - 'type' => 'radio', - 'options' => array( array( 'any', T_( 'All users') ), - array( 'loggedin', T_( 'Logged in users' ) ), - array( 'perms', T_( 'Users with messaging permissions only' ) ) ), - 'defaultvalue' => 'perms', - ), - 'show_badge' => array( - 'label' => T_( 'Show Badge' ), - 'note' => T_( 'Show a badge with the count of unread messages.' ), - 'type' => 'checkbox', - 'defaultvalue' => true, - ), - ), parent::get_param_definitions( $params ) ); - - // Do not modify anything during update because the editing form contains all of the required modifications - if( !isset( $params['for_updating'] ) ) - { // Not called from the update process - // Turn off allow blockcache by default, because it is forbidden in case of messages - // Note: we may call $this->get_param() only if this function was not called from there. This way we prevent infinite recursion/loop. - if( $this->get_param( 'link_type', $default_link_type ) == 'contacts' ) - { - $r['show_badge']['defaultvalue'] = false; - $r['show_badge']['disabled'] = 'disabled'; - } - } - - if( isset( $r['allow_blockcache'] ) ) - { // Disable "allow blockcache" because this widget uses the selected items - $r['allow_blockcache']['defaultvalue'] = false; - $r['allow_blockcache']['disabled'] = 'disabled'; - $r['allow_blockcache']['note'] = T_('This widget cannot be cached in the block cache.'); - } - - return $r; - } - - - /** - * Prepare display params - * - * @param array MUST contain at least the basic display params - */ - function init_display( $params ) - { - parent::init_display( $params ); - - // Disable "allow blockcache" because this widget uses the selected items - $this->disp_params['allow_blockcache'] = 0; - } - - - /** - * Display the widget! - * - * @param array MUST contain at least the basic display params - */ - function display( $params ) - { - global $Blog, $current_User, $disp; - - $this->init_display( $params ); - - $blog_ID = intval( $this->disp_params['blog_ID'] ); - if( $blog_ID > 0 ) - { // Try to use blog from widget setting - $BlogCache = & get_BlogCache(); - $current_Blog = & $BlogCache->get_by_ID( $blog_ID, false, false ); - } - - if( empty( $current_Blog ) ) - { // Blog is not defined in setting or it doesn't exist in DB - global $Collection, $Blog; - // Use current blog - $current_Blog = & $Blog; - } - - if( empty( $current_Blog ) ) - { // Don't use this widget without current collection: - $this->display_debug_message( 'Hidden(No collection)' ); - return false; - } - - if( $this->disp_params['visibility'] == 'access' && ! $current_Blog->has_access() ) - { // Don't use this widget because current user has no access to the collection: - $this->display_debug_message( 'Hidden(No access)' ); - return false; - } - - switch( $this->disp_params['show_to'] ) - { - case 'any': - break; - case 'loggedin': - if( !is_logged_in() ) - { - $this->display_debug_message( 'Hidden(Not logged in)' ); - return false; - } - break; - case 'perms': - if( !is_logged_in() || !$current_User->check_perm( 'perm_messaging', 'reply', false ) ) - { - $this->display_debug_message( 'Hidden(No access)' ); - return false; - } - break; // display - case 'default': - debug_die( 'Invalid params!' ); - } - - // Allow to higlight current menu item only when it is linked to current collection: - $highlight_current = ( $current_Blog->ID == $Blog->ID ); - - switch( $this->disp_params[ 'link_type' ] ) - { - case 'messages': - $url = $current_Blog->get( 'threadsurl' ); - $text = T_( 'Messages' ); - // set allow blockcache to 0, this way make sure block cache is never allowed for messages - $this->disp_params[ 'allow_blockcache' ] = 0; - // Check if current menu item must be highlighted: - $highlight_current = ( $highlight_current && ( ( $disp == 'threads' && ( ! isset( $_GET['disp'] ) || $_GET['disp'] != 'msgform' ) ) || $disp == 'messages' ) ); - break; - - case 'contacts': - $url = $current_Blog->get( 'contactsurl' ); - $text = T_( 'Contacts' ); - // set show badge to 0, this way make sure badge won't be displayed - $this->disp_params[ 'show_badge' ] = 0; - // Check if current menu item must be highlighted: - $highlight_current = ( $highlight_current && $disp == 'contacts' ); - break; - } - - if( !empty( $this->disp_params[ 'link_text' ] ) ) - { - $text = $this->disp_params[ 'link_text' ]; - } - - $badge = ''; - if( ( $this->disp_params[ 'show_badge' ] ) ) - { // Show badge with count of uread messages: - $unread_messages_count = get_unread_messages_count(); - if( $unread_messages_count > 0 ) - { // If at least one unread message: - $badge = ' '.$unread_messages_count.''; - if( isset( $this->BlockCache ) ) - { // Do not cache if bage is displayed because the number of unread messages are always changing: - $this->BlockCache->abort_collect(); - } - } - } - - // Display a layout with menu link: - echo $this->get_layout_standalone_menu_link( $url, $text.$badge, $highlight_current ); - - return true; - } -} - -?> \ No newline at end of file diff --git a/inc/widgets/widgets/_newsletter_subscription.widget.php b/inc/widgets/widgets/_newsletter_subscription.widget.php index 55ba3bb2ebf..4cdfc157179 100644 --- a/inc/widgets/widgets/_newsletter_subscription.widget.php +++ b/inc/widgets/widgets/_newsletter_subscription.widget.php @@ -247,20 +247,18 @@ function display( $params ) return false; } - echo $this->disp_params['block_start']; - - $redirect_to = param( 'redirect_to', 'url', regenerate_url( '', '', '', '&' ) ); - if( ! $widget_Newsletter || ! $widget_Newsletter->get( 'active' ) ) { // Display an error when newsletter is not found or not active: - $this->disp_title(); - echo $this->disp_params['block_body_start']; - echo '
    '.T_('List subscription widget references an inactive list.').'
    '; - echo $this->disp_params['block_body_end']; + $this->display_error_message( T_('List subscription widget references an inactive list.') ); + return false; } - else - { // Display a form to subscribe⁄unsubscribe: + + echo $this->disp_params['block_start']; + + $redirect_to = param( 'redirect_to', 'url', regenerate_url( '', '', '', '&' ) ); + + // Display a form to subscribe⁄unsubscribe: $check_tag = false; if( $this->disp_params['unsubscribed_if_not_tagged'] && ! empty( $this->disp_params['usertags'] ) ) { @@ -345,7 +343,6 @@ function display( $params ) } echo $this->disp_params['block_body_end']; - } echo $this->disp_params['block_end']; diff --git a/inc/widgets/widgets/_param_switcher.widget.php b/inc/widgets/widgets/_param_switcher.widget.php index 11454dca7f6..3cd78585d5d 100644 --- a/inc/widgets/widgets/_param_switcher.widget.php +++ b/inc/widgets/widgets/_param_switcher.widget.php @@ -87,8 +87,11 @@ function get_param_definitions( $params ) { $r = array_merge( array( 'param_code' => array( + 'type' => 'text', 'label' => T_('Param code'), 'size' => 60, + 'allow_empty' => false, + 'defaultvalue' => 'tab', ), 'buttons' => array( 'type' => 'array', @@ -175,11 +178,16 @@ function display( $params ) $this->init_display( $params ); if( ! isset( $Item ) || - ! $Item instanceof Item || - ! $Item->get_type_setting( 'allow_switchable' ) || + ! $Item instanceof Item ) + { // No current Item: + $this->display_debug_message( 'Widget "'.$this->get_name().'" is hidden because this is not an Item page, so there can be no switcher params.' ); + return false; + } + + if( ! $Item->get_type_setting( 'allow_switchable' ) || ! $Item->get_setting( 'switchable' ) ) - { // No current Item or Item doesn't use a switcher: - $this->display_debug_message( 'Widget "'.$this->get_name().'" is hidden because current Item does not use swicther params.' ); + { // Item doesn't use switcher params: + $this->display_debug_message( 'Widget "'.$this->get_name().'" is hidden because current Item does not use switcher params.' ); return false; } @@ -295,37 +303,29 @@ function display_switchable_tabs( $buttons, $defaults = array() ) $item_start = $this->get_menu_link_item_start( true ); preg_match( '/class="([^"]+)"/i', $item_start, $match_class ); $wrapper_class_active = empty( $match_class[1] ) ? '' : $match_class[1]; -?> - - 'a[data-param-switcher][data-code='.$this->get_param( 'param_code' ).']', + 'link_class_normal' => $this->get_link_class( false ), + 'link_class_active' => $this->get_link_class( true ), + 'wrapper_class_normal' => $wrapper_class_normal, + 'wrapper_class_active' => $wrapper_class_active, + 'add_redir_no' => $this->get_param( 'add_redir_no' ) ? true : false, + 'defaults' => $defaults, + 'display_mode' => $this->get_display_mode(), + ); + expose_var_to_js( 'param_switcher_'.$this->get_param( 'param_code' ), $switchable_buttons_config, 'evo_init_switchable_buttons_config' ); + + // NOTE: These JS files must be included inline here in order to make + // it works for short/inline tags [switcher:...] [option:...]...[/option] [/switcher] + // because for them we cannot call Widget->request_required_files() to include JS files in + // WARNING: Cannot uglify evo_switchable_blocks.js because of the arrow function there. + require_js_defer( '#jquery#', 'blog', true ); + require_js_defer( 'src/evo_switchable_blocks.js', 'blog', true ); } return $active_button_value; } - - - /** - * Request all required css and js files for this widget - */ - function request_required_files() - { - if( $this->get_param( 'allow_switch_js' ) ) - { // Load JS to switch between blocks on change URL in address bar: - require_js( '#jquery#', 'blog' ); - require_js( 'src/evo_switchable_blocks.js', 'blog' ); - } - } } ?> \ No newline at end of file diff --git a/inc/widgets/widgets/_poll.widget.php b/inc/widgets/widgets/_poll.widget.php index 5a5e18629b7..a4fbf31a5d0 100644 --- a/inc/widgets/widgets/_poll.widget.php +++ b/inc/widgets/widgets/_poll.widget.php @@ -101,6 +101,23 @@ function display( $params ) { $this->init_display( $params ); + $PollCache = & get_PollCache(); + $Poll = $PollCache->get_by_ID( $this->disp_params['poll_ID'], false, false ); + + if( ! $Poll ) + { // We cannot find a poll by the entered ID in widget settings: + $this->display_error_message( sprintf( T_('Poll ID %s not found.'), ''.format_to_output( $this->disp_params['poll_ID'], 'text' ).'' ) ); + return false; + } + + $poll_options = $Poll->get_poll_options(); + + if( empty( $poll_options ) ) + { // Display this red message to inform admin to create the poll options: + $this->display_error_message( T_('This poll doesn\'t contain any answer.') ); + return false; + } + // START DISPLAY: echo $this->disp_params['block_start']; @@ -109,31 +126,19 @@ function display( $params ) echo $this->disp_params['block_body_start']; - $PollCache = & get_PollCache(); - $Poll = $PollCache->get_by_ID( $this->disp_params['poll_ID'], false, false ); - - if( ! $Poll ) - { // We cannot find a poll by the entered ID in widget settings: - echo '

    '.sprintf( T_('Poll ID %s not found.'), ''.format_to_output( $this->disp_params['poll_ID'], 'text' ).'' ).'

    '; - } - else - { // Display a form for voting on poll: + // Display a form for voting on poll: $poll_question = empty( $this->disp_params['poll_question'] ) ? $Poll->get( 'question_text' ) : $this->disp_params['poll_question']; if( $poll_question !== '-' ) { // Display a poll question only when it doesn't equal "-": echo '

    '.$poll_question.'

    '; } - $poll_options = $Poll->get_poll_options(); - if( $Poll->get( 'max_answers' ) < count( $poll_options ) ) { echo '

    '.sprintf( T_('Select up to %d answers below.'), $Poll->get( 'max_answers' ) ).'

    '; } - - if( count( $poll_options ) ) - { // Display a form only if at least one poll option exists: + // Display a form only if at least one poll option exists: if( is_logged_in() ) { // Set form action to vote if current user is logged in: $form_action = get_htsrv_url().'action.php?mname=polls'; @@ -197,38 +202,8 @@ function display( $params ) } echo ''; - global $evo_poll_answer_JS_is_initialized; - if( empty( $evo_poll_answer_JS_is_initialized ) || $Poll->get( 'max_answers' ) > 1 ) - { // Initialize JS code to restrict max answers per user and Fix answer long text width: - ?> - - end_form(); - } - else - { // Display this red message to inform admin to create the poll options: - echo '

    '.T_('This poll doesn\'t contain any answer.').'

    '; - } - } echo $this->disp_params['block_body_end']; @@ -255,4 +224,4 @@ function display( $params ) return true; } -} \ No newline at end of file +} diff --git a/inc/widgets/widgets/_profile_menu_link.widget.php b/inc/widgets/widgets/_profile_menu_link.widget.php deleted file mode 100644 index 4f687907e25..00000000000 --- a/inc/widgets/widgets/_profile_menu_link.widget.php +++ /dev/null @@ -1,218 +0,0 @@ -get_name(); - } - - - /** - * Get short description - */ - function get_desc() - { - return T_('Link to current user profile, including profile picture'); - } - - - /** - * Get definitions for editable params - * - * @see Plugin::GetDefaultSettings() - * @param local params like 'for_editing' => true - */ - function get_param_definitions( $params ) - { - global $admin_url; - - load_funcs( 'files/model/_image.funcs.php' ); - - // Try to get collection that is used for messages on this site: - $msg_Blog = & get_setting_Blog( 'msg_blog_ID' ); - - $r = array_merge( array( - 'profile_picture_size' => array( - 'label' => T_('Profile picture size'), - 'note' => '', - 'type' => 'select', - 'options' => get_available_thumb_sizes(), - 'defaultvalue' => 'crop-top-15x15', - ), - 'blog_ID' => array( - 'label' => T_('Collection ID'), - 'note' => T_('Leave empty for current collection.') - .( $msg_Blog ? ' '.sprintf( T_('The site is configured to always use collection %s for profiles/messaging functions.'), - 'href="'.$admin_url.'?ctrl=collections&tab=site_settings"', - ''.$msg_Blog->get( 'name' ).'' ).'' : '' ), - 'type' => 'integer', - 'allow_empty' => true, - 'size' => 5, - 'defaultvalue' => '', - 'disabled' => $msg_Blog ? 'disabled' : false, - ), - 'visibility' => array( - 'label' => T_( 'Visibility' ), - 'note' => '', - 'type' => 'radio', - 'options' => array( - array( 'always', T_( 'Always show (cacheable)') ), - array( 'access', T_( 'Only show if access is allowed (not cacheable)' ) ) ), - 'defaultvalue' => 'always', - 'field_lines' => true, - ), - ), parent::get_param_definitions( $params ) ); - - if( isset( $r['allow_blockcache'] ) ) - { // Disable "allow blockcache" because this widget uses the selected items - $r['allow_blockcache']['defaultvalue'] = false; - $r['allow_blockcache']['disabled'] = 'disabled'; - $r['allow_blockcache']['note'] = T_('This widget cannot be cached in the block cache.'); - } - - return $r; - } - - - /** - * Prepare display params - * - * @param array MUST contain at least the basic display params - */ - function init_display( $params ) - { - $params = array_merge( array( - 'profile_menu_link_text' => 'avatar_name', - ), $params ); - - parent::init_display( $params ); - - // Disable "allow blockcache" because this widget uses the selected items - $this->disp_params['allow_blockcache'] = 0; - } - - - /** - * Display the widget! - * - * @param array MUST contain at least the basic display params - */ - function display( $params ) - { - global $current_User, $disp, $Blog; - - if( ! is_logged_in() ) - { // Only logged in users can see this menu item: - $this->display_debug_message( 'Hidden(Not logged in)' ); - return false; - } - - $this->init_display( $params ); - - $blog_ID = intval( $this->disp_params['blog_ID'] ); - if( $blog_ID > 0 ) - { // Try to use collection from widget setting: - $BlogCache = & get_BlogCache(); - $current_Blog = & $BlogCache->get_by_ID( $blog_ID, false, false ); - } - - if( empty( $current_Blog ) ) - { // Use current collection if collection is not defined in setting or it doesn't exist in DB: - $current_Blog = $Blog; - } - - if( empty( $current_Blog ) ) - { // Don't use this widget without current collection: - $this->display_debug_message( 'Hidden(No collection)' ); - return false; - } - - if( $this->disp_params['visibility'] == 'access' && ! $current_Blog->has_access() ) - { // Don't use this widget because current user has no access to the collection: - $this->display_debug_message( 'Hidden(No access)' ); - return false; - } - - // Default link class - $link_class = $this->disp_params['link_default_class']; - - // set allow blockcache to 0, this way make sure block cache is never allowed for menu items that can be selected - $this->disp_params[ 'allow_blockcache' ] = 0; - - // Higlight current menu item only when it is linked to current collection and user profile page is displaying currently: - $highlight_current = ( $current_Blog->ID == $Blog->ID && $disp == 'user' ); - - // Display a layout with menu link: - $menu_link_template = $current_User->get_identity_link( array( - 'display_bubbletip' => false, - 'thumb_class' => 'avatar_before_login_middle', - 'thumb_size' => $this->disp_params['profile_picture_size'], - 'link_class' => '$link_class$', - 'blog_ID' => $current_Blog->ID, - 'link_text' => $this->disp_params['profile_menu_link_text'], - ) ); - echo $this->get_layout_standalone_menu_link( '', '', $highlight_current, $menu_link_template ); - - return true; - } -} - -?> \ No newline at end of file diff --git a/inc/widgets/widgets/_request_title.widget.php b/inc/widgets/widgets/_request_title.widget.php new file mode 100644 index 00000000000..136e58c7329 --- /dev/null +++ b/inc/widgets/widgets/_request_title.widget.php @@ -0,0 +1,128 @@ +get_name(); + } + + + /** + * Get short description + */ + function get_desc() + { + return T_('Display comment header title.'); + } + + + /** + * Get definitions for editable params + * + * @see Plugin::GetDefaultSettings() + * @param local params like 'for_editing' => true + */ + function get_param_definitions( $params ) + { + $r = parent::get_param_definitions( $params ); + + if( isset( $r['allow_blockcache'] ) ) + { // Disable "allow blockcache" because this widget is used to display title of different pages: + $r['allow_blockcache']['defaultvalue'] = false; + $r['allow_blockcache']['disabled'] = 'disabled'; + $r['allow_blockcache']['note'] = T_('This widget cannot be cached in the block cache.'); + } + + return $r; + } + + + /** + * Display the widget! + * + * @param array MUST contain at least the basic display params + */ + function display( $params ) + { + global $Collection, $Blog, $is_front; + + $this->init_display( $params ); + + // Comment header title: + echo $this->disp_params['block_start']; + + request_title( array( + 'title_before' => '

    ', + 'title_after' => '

    ', + 'title_none' => '', + 'glue' => ' - ', + 'title_single_disp' => false, + 'title_page_disp' => false, + 'format' => 'htmlbody', + ) ); + + echo $this->disp_params['block_end']; + + return true; + } +} + +?> \ No newline at end of file diff --git a/inc/widgets/widgets/_site_logo.widget.php b/inc/widgets/widgets/_site_logo.widget.php index fa526425dd8..2baad289818 100644 --- a/inc/widgets/widgets/_site_logo.widget.php +++ b/inc/widgets/widgets/_site_logo.widget.php @@ -140,7 +140,7 @@ function get_param_definitions( $params ) ), 'height' => array( 'label' => T_('Image height'), - 'note' => '', + 'note' => T_('Leave blank for auto.'), 'defaultvalue' => '', 'allow_empty' => true, 'size' => 4, @@ -151,7 +151,6 @@ function get_param_definitions( $params ) ), 'size_end_line' => array( 'type' => 'end_line', - 'label' => T_('Leave blank for auto.'), ), 'alt' => array( 'label' => T_('Image Alt text'), diff --git a/inc/widgets/widgets/_user_action.widget.php b/inc/widgets/widgets/_user_action.widget.php index aac713a76a0..ef2f36a0279 100644 --- a/inc/widgets/widgets/_user_action.widget.php +++ b/inc/widgets/widgets/_user_action.widget.php @@ -151,8 +151,8 @@ function display( $params ) case 'add_contact': // Add to Contacts: if( is_logged_in() && ( $current_User->ID != $target_User->ID ) && - $current_User->check_perm( 'perm_messaging', 'reply' ) && - $current_User->check_status( 'can_edit_contacts' ) ) + check_user_perm( 'perm_messaging', 'reply' ) && + check_user_status( 'can_edit_contacts' ) ) { // User is logged in, has messaging access permission and is not the same user as displayed user: $is_contact = check_contact( $target_User->ID ); if( $is_contact === NULL ) @@ -179,8 +179,8 @@ function display( $params ) // Block Contact: if( is_logged_in() && ( $current_User->ID != $target_User->ID ) && - $current_User->check_perm( 'perm_messaging', 'reply' ) && - $current_User->check_status( 'can_edit_contacts' ) ) + check_user_perm( 'perm_messaging', 'reply' ) && + check_user_status( 'can_edit_contacts' ) ) { // User is logged in, has messaging access permission and is not the same user as displayed user: $is_contact = check_contact( $target_User->ID ); $contact_block_url = get_samedomain_htsrv_url().'action.php?mname=messaging&disp=contacts&user_ID='.$target_User->ID.'&redirect_to='.rawurlencode( regenerate_url() ).'&'.url_crumb( 'messaging_contacts' ); @@ -200,7 +200,7 @@ function display( $params ) // Report User: if( is_logged_in() && ( $current_User->ID != $target_User->ID ) && - $current_User->check_status( 'can_report_user', $target_User->ID ) ) + check_user_status( 'can_report_user', $target_User->ID ) ) { // Current user must be logged in, cannot report own account, and must has a permission to report: // Get current User report from edited User: $current_report = get_report_from( $target_User->ID ); @@ -221,8 +221,8 @@ function display( $params ) // Edit in Back-Office: if( is_logged_in() && $current_User->can_moderate_user( $target_User->ID ) && - $current_User->check_status( 'can_access_admin' ) && - $current_User->check_perm( 'admin', 'restricted' ) + check_user_status( 'can_access_admin' ) && + check_user_perm( 'admin', 'restricted' ) ) { // Current user must has an access to back-office and moderate the target user: global $admin_url; @@ -237,9 +237,9 @@ function display( $params ) if( is_logged_in() && $target_User->ID != 1 && $current_User->ID != $target_User->ID && - $current_User->check_status( 'can_access_admin' ) && - $current_User->check_perm( 'admin', 'restricted' && - $current_User->check_perm( 'users', 'edit' ) ) + check_user_status( 'can_access_admin' ) && + check_user_perm( 'admin', 'restricted' && + check_user_perm( 'users', 'edit' ) ) ) { // Current user must has an access to back-office and delete the target user: global $admin_url; diff --git a/inc/widgets/widgets/_user_links.widget.php b/inc/widgets/widgets/_user_links.widget.php index fcf579dbd38..d0149a5ddd7 100644 --- a/inc/widgets/widgets/_user_links.widget.php +++ b/inc/widgets/widgets/_user_links.widget.php @@ -142,7 +142,7 @@ function display( $params ) $target_User = & $this->get_target_User(); if( empty( $target_User ) ) { // No user detected - $r .= '

    '.sprintf( T_('User %s not found.'), ''.format_to_output( $this->disp_params['login'], 'text' ).'' ).'

    '; + $r .= get_rendering_error( sprintf( T_('User %s not found.'), ''.format_to_output( $this->disp_params['login'], 'text' ).'' ) ); } if( ! empty( $target_User ) ) diff --git a/inc/widgets/widgets/_user_login.widget.php b/inc/widgets/widgets/_user_login.widget.php index a1464928ae0..26d1aa2c785 100644 --- a/inc/widgets/widgets/_user_login.widget.php +++ b/inc/widgets/widgets/_user_login.widget.php @@ -164,7 +164,7 @@ function request_required_files() //get required js files for _widget_login.form if( can_use_hashed_password() ) { // Include JS for client-side password hashing: - require_js( 'build/sha1_md5.bmin.js', 'blog' ); + require_js_defer( 'build/sha1_md5.bmin.js', 'blog' ); } } diff --git a/inc/widgets/widgets/_user_profile_pics.widget.php b/inc/widgets/widgets/_user_profile_pics.widget.php index c1a79ba5d73..6ba68c73489 100644 --- a/inc/widgets/widgets/_user_profile_pics.widget.php +++ b/inc/widgets/widgets/_user_profile_pics.widget.php @@ -189,7 +189,7 @@ function display( $params ) if( $this->get_param( 'display_other' ) ) { // Display additional pictures: - if( is_logged_in() && $current_User->check_status( 'can_view_user', $target_User->ID ) ) + if( check_user_status( 'can_view_user', $target_User->ID ) ) { // Only for logged in and activated users $user_pictures = $target_User->get_avatar_Links(); if( count( $user_pictures ) > 0 ) diff --git a/inc/widgets/widgets/_user_register_standard.widget.php b/inc/widgets/widgets/_user_register_standard.widget.php index c8223da1cef..8ed99965563 100644 --- a/inc/widgets/widgets/_user_register_standard.widget.php +++ b/inc/widgets/widgets/_user_register_standard.widget.php @@ -83,13 +83,6 @@ function get_desc() */ function get_param_definitions( $params ) { - global $current_User, $admin_url; - - // Get available templates: - $context = 'registration'; - $TemplateCache = & get_TemplateCache(); - $TemplateCache->load_by_context( $context ); - $r = array_merge( array( 'title' => array( 'label' => T_('Block title'), @@ -251,9 +244,7 @@ function display( $params ) { foreach( $missing_fields as $missing_field ) { - echo '

    '; - echo sprintf( T_('The template %s is missing the required field %s.'), ''.$this->disp_params['reg1_template'].'', ''.$missing_field.'' ); - echo '

    '; + display_rendering_error( sprintf( T_('The template %s is missing the required field %s.'), ''.$this->disp_params['reg1_template'].'', ''.$missing_field.'' ) ); } } @@ -362,7 +353,7 @@ function display( $params ) $Form->end_form(); // Display javascript password strength indicator bar: - display_password_indicator( array( 'field-width' => $params['register_field_width'] ) ); + display_password_indicator( array( 'field_width' => $params['register_field_width'] ) ); // Display javascript login validator: display_login_validator(); diff --git a/inc/widgets/widgets/_user_tools.widget.php b/inc/widgets/widgets/_user_tools.widget.php deleted file mode 100644 index e0d63640c98..00000000000 --- a/inc/widgets/widgets/_user_tools.widget.php +++ /dev/null @@ -1,375 +0,0 @@ - true - */ - function get_param_definitions( $params ) - { - $r = array_merge( array( - 'title' => array( - 'label' => T_('Block title'), - 'note' => T_( 'Title to display in your skin.' ), - 'size' => 40, - 'defaultvalue' => T_('User tools'), - ), - // Write new post - disp=edit - 'user_postnew_link_show' => array( - 'label' => T_( 'Write a new post link'), - 'note' => T_( 'Show link' ), - 'type' => 'checkbox', - 'defaultvalue' => 1, - ), - 'user_postnew_link' => array( - 'size' => 30, - 'note' => T_( 'Link text to display' ), - 'type' => 'text', - 'defaultvalue' => T_( 'Write a new post...' ), - ), - // Messaging - disp=threads - 'user_messaging_link_show' => array( - 'label' => T_( 'Messaging area link'), - 'note' => T_( 'Show link' ), - 'type' => 'checkbox', - 'defaultvalue' => 1, - ), - 'show_badge' => array( - 'label' => T_( 'Show Badge' ), - 'note' => T_( 'Show a badge with the count of unread messages.' ), - 'type' => 'checkbox', - 'defaultvalue' => true, - ), - 'user_messaging_link' => array( - 'size' => 30, - 'note' => T_( 'Link text to display' ), - 'type' => 'text', - 'defaultvalue' => T_( 'My messages' ), - ), - // Contacts - disp=contacts - 'user_contacts_link_show' => array( - 'label' => T_( 'Contacts link'), - 'note' => T_( 'Show link' ), - 'type' => 'checkbox', - 'defaultvalue' => 1, - ), - 'user_contacts_link' => array( - 'size' => 30, - 'note' => T_( 'Link text to display' ), - 'type' => 'text', - 'defaultvalue' => T_( 'My contacts' ), - ), - // See profile - disp=user - 'user_view_link_show' => array( - 'label' => T_( 'See profile link'), - 'note' => T_( 'Show link' ), - 'type' => 'checkbox', - 'defaultvalue' => 1, - ), - 'user_view_link' => array( - 'size' => 30, - 'note' => T_( 'Link text to display' ), - 'type' => 'text', - 'defaultvalue' => T_( 'My profile' ), - ), - // Edit profile - disp=profile - 'user_profile_link_show' => array( - 'label' => T_( 'Edit profile link'), - 'note' => T_( 'Show link' ), - 'type' => 'checkbox', - 'defaultvalue' => 1, - ), - 'user_profile_link' => array( - 'size' => 30, - 'note' => T_( 'Link text to display' ), - 'type' => 'text', - 'defaultvalue' => T_( 'Edit my profile' ), - ), - // Edit picture - disp=avatar - 'user_picture_link_show' => array( - 'label' => T_( 'Edit profile picture link'), - 'note' => T_( 'Show link' ), - 'type' => 'checkbox', - 'defaultvalue' => 1, - ), - 'user_picture_link' => array( - 'size' => 30, - 'note' => T_( 'Link text to display' ), - 'type' => 'text', - 'defaultvalue' => T_( 'Change my picture' ), - ), - // Edit password - disp=pwdchange - 'user_password_link_show' => array( - 'label' => T_( 'Edit password link'), - 'note' => T_( 'Show link' ), - 'type' => 'checkbox', - 'defaultvalue' => 0, - ), - 'user_password_link' => array( - 'size' => 30, - 'note' => T_( 'Link text to display' ), - 'type' => 'text', - 'defaultvalue' => T_( 'Change my password' ), - ), - // Edit preferences - disp=userprefs - 'user_preferences_link_show' => array( - 'label' => T_( 'Edit preferences link'), - 'note' => T_( 'Show link' ), - 'type' => 'checkbox', - 'defaultvalue' => 0, - ), - 'user_preferences_link' => array( - 'size' => 30, - 'note' => T_( 'Link text to display' ), - 'type' => 'text', - 'defaultvalue' => T_( 'Change my preferences' ), - ), - // Edit notifications - disp=subs - 'user_subs_link_show' => array( - 'label' => T_( 'Edit notifications link'), - 'note' => T_( 'Show link' ), - 'type' => 'checkbox', - 'defaultvalue' => 0, - ), - 'user_subs_link' => array( - 'size' => 30, - 'note' => T_( 'Link text to display' ), - 'type' => 'text', - 'defaultvalue' => T_( 'Notifications & Subscriptions' ), - ), - // Admin - 'user_admin_link_show' => array( - 'label' => T_( 'Admin link'), - 'note' => T_( 'Show link' ), - 'type' => 'checkbox', - 'defaultvalue' => 1, - ), - 'user_admin_link' => array( - 'size' => 30, - 'note' => T_( 'Link text to display' ), - 'type' => 'text', - 'defaultvalue' => T_( 'Admin area' ), - ), - // Logout - 'user_logout_link_show' => array( - 'label' => T_( 'Logout link'), - 'note' => T_( 'Show link' ), - 'type' => 'checkbox', - 'defaultvalue' => 1, - ), - 'user_logout_link' => array( - 'size' => 30, - 'note' => T_( 'Link text to display' ), - 'type' => 'text', - 'defaultvalue' => T_( 'Log out' ), - ), - ), parent::get_param_definitions( $params ) ); - - if( isset( $r['allow_blockcache'] ) ) - { // Set default blockcache to false and disable this setting because caching is never allowed for this widget - $r['allow_blockcache']['defaultvalue'] = false; - $r['allow_blockcache']['disabled'] = 'disabled'; - $r['allow_blockcache']['note'] = T_('This widget cannot be cached in the block cache.'); - } - - return $r; - } - - - /** - * Get help URL - * - * @return string URL - */ - function get_help_url() - { - return get_manual_url( 'user-tools-widget' ); - } - - - /** - * Get name of widget - */ - function get_name() - { - return T_('User Tools'); - } - - - /** - * Get a very short desc. Used in the widget list. - */ - function get_short_desc() - { - return format_to_output($this->disp_params['title']); - } - - - /** - * Get short description - */ - function get_desc() - { - return T_('DEPRECATED').' - '.T_('Display user tools: Log in, Admin, Profile, Subscriptions, Log out'); - } - - - /** - * Display the widget! - * - * @param array MUST contain at least the basic display params - */ - function display( $params ) - { - if( !is_logged_in() ) - { // Only logged in users can see this tools panel - $this->display_debug_message( 'Widget "'.$this->get_name().'" is hidden because you are not logged in.' ); - return false; - } - - $this->init_display( $params ); // just in case it hasn't been done before - - $this->disp_params['item_start'] .= ''; - $this->disp_params['item_end'] = ''.$this->disp_params['item_end']; - - $tools_links = ''; - if( $this->get_param('user_postnew_link_show') ) - { // Write new post - disp=edit - $tools_links .= get_item_new_link( $this->disp_params['item_start'], $this->disp_params['item_end'], $this->disp_params[ 'user_postnew_link' ] ); - } - if( $this->get_param('user_messaging_link_show') ) - { // Messaging - disp=threads - $tools_links .= get_user_messaging_link( $this->disp_params['item_start'], $this->disp_params['item_end'], $this->disp_params[ 'user_messaging_link' ], $this->disp_params[ 'user_messaging_link' ], $this->disp_params[ 'show_badge' ] ); - } - if( $this->get_param('user_contacts_link_show') ) - { // Contacts - disp=contacts - $tools_links .= get_user_contacts_link( $this->disp_params['item_start'], $this->disp_params['item_end'], $this->disp_params[ 'user_contacts_link' ], $this->disp_params[ 'user_contacts_link' ] ); - } - if( $this->get_param('user_view_link_show') ) - { // See profile - disp=user - $tools_links .= get_user_tab_link( 'user', $this->disp_params['item_start'], $this->disp_params['item_end'], $this->disp_params[ 'user_view_link' ], $this->disp_params[ 'user_view_link' ] ); - } - if( $this->get_param('user_profile_link_show') ) - { // Edit profile - disp=profile - $tools_links .= get_user_profile_link( $this->disp_params['item_start'], $this->disp_params['item_end'], $this->disp_params[ 'user_profile_link' ], $this->disp_params[ 'user_profile_link' ] ); - } - if( $this->get_param('user_picture_link_show') ) - { // Edit picture - disp=avatar - $tools_links .= get_user_tab_link( 'avatar', $this->disp_params['item_start'], $this->disp_params['item_end'], $this->disp_params[ 'user_picture_link' ], $this->disp_params[ 'user_picture_link' ] ); - } - if( $this->get_param('user_password_link_show') ) - { // Edit password - disp=pwdchange - $tools_links .= get_user_tab_link( 'pwdchange', $this->disp_params['item_start'], $this->disp_params['item_end'], $this->disp_params[ 'user_password_link' ], $this->disp_params[ 'user_password_link' ] ); - } - if( $this->get_param('user_preferences_link_show') ) - { // Edit preferences - disp=userprefs - $tools_links .= get_user_tab_link( 'userprefs', $this->disp_params['item_start'], $this->disp_params['item_end'], $this->disp_params[ 'user_preferences_link' ], $this->disp_params[ 'user_preferences_link' ] ); - } - if( $this->get_param('user_subs_link_show') ) - { // Edit notifications - disp=subs - $tools_links .= get_user_subs_link( $this->disp_params['item_start'], $this->disp_params['item_end'], $this->disp_params[ 'user_subs_link' ], $this->disp_params[ 'user_subs_link' ] ); - } - if( $this->get_param('user_admin_link_show') ) - { // Admin - $tools_links .= get_user_admin_link( $this->disp_params['item_start'], $this->disp_params['item_end'], $this->disp_params[ 'user_admin_link' ] ); - } - if( $this->get_param('user_logout_link_show') ) - { // Logout - $tools_links .= get_user_logout_link( $this->disp_params['item_start'], $this->disp_params['item_end'], $this->disp_params[ 'user_logout_link' ] ); - } - - if( empty( $tools_links ) ) - { // No available links to display - $this->display_debug_message( 'Widget "'.$this->get_name().'" is hidden because no available links to display.' ); - return false; - } - - // User tools: - echo $this->disp_params['block_start']; - - if( !empty( $this->disp_params['title'] ) ) - { // Display title - echo $this->disp_params['block_title_start']; - echo $this->disp_params['title']; - echo $this->disp_params['block_title_end']; - } - - echo $this->disp_params['block_body_start']; - - echo $this->disp_params['list_start']; - - echo $tools_links; - - if( isset($this->BlockCache) ) - { // Do NOT cache because some of these links are using a redirect_to param, which makes it page dependent. - // Note: also beware of the source param. - // so this will be cached by the PageCache; there is no added benefit to cache it in the BlockCache - // (which could have been shared between several pages): - $this->BlockCache->abort_collect(); - } - - echo $this->disp_params['list_end']; - - echo $this->disp_params['block_body_end']; - - echo $this->disp_params['block_end']; - } - - - /** - * Maybe be overriden by some widgets, depending on what THEY depend on.. - * - * @return array of keys this widget depends on - */ - function get_cache_keys() - { - global $Collection, $Blog, $current_User; - - return array( - 'wi_ID' => $this->ID, // Have the widget settings changed ? - 'set_coll_ID' => $Blog->ID, // Have the settings of the blog changed ? (ex: new owner, new skin) - 'loggedin' => (is_logged_in() ? 1 : 0), - // fp> note: if things get tough in the future, use a per User caching scheme: - // 'user_ID' => (is_logged_in() ? $current_User->ID : 0), // Has the current User changed? - ); - } -} - -?> \ No newline at end of file diff --git a/inc/xmlrpc/apis/_blogger.api.php b/inc/xmlrpc/apis/_blogger.api.php index 90234a1da0c..b5dbf57453b 100644 --- a/inc/xmlrpc/apis/_blogger.api.php +++ b/inc/xmlrpc/apis/_blogger.api.php @@ -138,7 +138,7 @@ function blogger_editpost($m) } // We need to be able to edit this post: - if( ! $current_User->check_perm( 'item_post!CURSTATUS', 'edit', false, $edited_Item ) ) + if( ! check_user_perm( 'item_post!CURSTATUS', 'edit', false, $edited_Item ) ) { return xmlrpcs_resperror( 3 ); // Permission denied } @@ -416,7 +416,7 @@ function blogger_getrecentposts( $m ) // Protected and private get checked by statuses_where_clause(). $statuses = array( 'published', 'redirected', 'protected', 'private' ); - if( $current_User->check_perm( 'blog_ismember', 'view', false, $Blog->ID ) ) + if( check_user_perm( 'blog_ismember', 'view', false, $Blog->ID ) ) { // These statuses require member status: $statuses = array_merge( $statuses, array( 'draft', 'deprecated' ) ); } diff --git a/inc/xmlrpc/apis/_metaweblog.api.php b/inc/xmlrpc/apis/_metaweblog.api.php index 666f5eaf375..432996c0f81 100644 --- a/inc/xmlrpc/apis/_metaweblog.api.php +++ b/inc/xmlrpc/apis/_metaweblog.api.php @@ -219,7 +219,7 @@ function mw_editpost( $m, $item_type = 'post' ) } // We need to be able to edit this post: - if( ! $current_User->check_perm( 'item_post!CURSTATUS', 'edit', false, $edited_Item ) ) + if( ! check_user_perm( 'item_post!CURSTATUS', 'edit', false, $edited_Item ) ) { return xmlrpcs_resperror( 3 ); // Permission denied } diff --git a/inc/xmlrpc/apis/_mt.api.php b/inc/xmlrpc/apis/_mt.api.php index 888c820f147..339f605aa4c 100644 --- a/inc/xmlrpc/apis/_mt.api.php +++ b/inc/xmlrpc/apis/_mt.api.php @@ -63,7 +63,7 @@ function mt_setPostCategories($m) return xmlrpcs_resperror(); } - if( ! $current_User->check_perm( 'item_post!CURSTATUS', 'edit', false, $edited_Item ) ) + if( ! check_user_perm( 'item_post!CURSTATUS', 'edit', false, $edited_Item ) ) { // Permission denied return xmlrpcs_resperror( 3 ); } @@ -102,7 +102,7 @@ function mt_setPostCategories($m) } // CHECK PERMISSION: (we need perm on all categories, especially if they are in different blogs) - if( ! $current_User->check_perm( 'cats_post!'.$edited_Item->status, 'edit', false, $categories ) ) + if( ! check_user_perm( 'cats_post!'.$edited_Item->status, 'edit', false, $categories ) ) { // Permission denied return xmlrpcs_resperror( 3 ); // User error 3 } @@ -251,8 +251,8 @@ function mt_publishPost($m) return xmlrpcs_resperror(); } - if( ! $current_User->check_perm( 'item_post!published', 'edit', false, $edited_Item ) - /*|| ! $current_User->check_perm( 'edit_timestamp' )*/ ) + if( ! check_user_perm( 'item_post!published', 'edit', false, $edited_Item ) + /*|| ! check_user_perm( 'edit_timestamp' )*/ ) { return xmlrpcs_resperror( 3 ); // Permission denied } diff --git a/inc/xmlrpc/apis/_wordpress.api.php b/inc/xmlrpc/apis/_wordpress.api.php index b5b590d4ecb..e38ad63348e 100644 --- a/inc/xmlrpc/apis/_wordpress.api.php +++ b/inc/xmlrpc/apis/_wordpress.api.php @@ -79,7 +79,7 @@ function wp_getauthors($m) return xmlrpcs_resperror(); } - if( ! $current_User->check_perm('users', 'view') ) + if( ! check_user_perm('users', 'view') ) { return xmlrpcs_resperror( 5, T_('You have no permission to view other users!') ); } @@ -210,7 +210,7 @@ function wp_getpagelist( $m ) // Protected and private get checked by statuses_where_clause(). $statuses = array( 'published', 'redirected', 'protected', 'private' ); - if( $current_User->check_perm( 'blog_ismember', 'view', false, $Blog->ID ) ) + if( check_user_perm( 'blog_ismember', 'view', false, $Blog->ID ) ) { // These statuses require member status: $statuses = array_merge( $statuses, array( 'draft', 'deprecated' ) ); } @@ -395,32 +395,32 @@ function wp_getpagestatuslist( $m ) $status_list = array(); - if( $current_User->check_perm( 'blog_post!published', 'edit', false, $Blog->ID ) ) + if( check_user_perm( 'blog_post!published', 'edit', false, $Blog->ID ) ) { $status_list[ wp_or_b2evo_item_status('published', 'wp') ] = new xmlrpcval(T_('Published')) ; } - if( $current_User->check_perm( 'blog_post!protected', 'edit', false, $Blog->ID ) ) + if( check_user_perm( 'blog_post!protected', 'edit', false, $Blog->ID ) ) { // Not supported by WP, maps to 'private' $status_list[ wp_or_b2evo_item_status('protected', 'wp') ] = new xmlrpcval(T_('Protected')) ; } - if( $current_User->check_perm( 'blog_post!private', 'edit', false, $Blog->ID ) ) + if( check_user_perm( 'blog_post!private', 'edit', false, $Blog->ID ) ) { $status_list[ wp_or_b2evo_item_status('private', 'wp') ] = new xmlrpcval(T_('Private')) ; } - if( $current_User->check_perm( 'blog_post!draft', 'edit', false, $Blog->ID ) ) + if( check_user_perm( 'blog_post!draft', 'edit', false, $Blog->ID ) ) { $status_list[ wp_or_b2evo_item_status('draft', 'wp') ] = new xmlrpcval(T_('Draft')) ; } - if( $current_User->check_perm( 'blog_post!deprecated', 'edit', false, $Blog->ID ) ) + if( check_user_perm( 'blog_post!deprecated', 'edit', false, $Blog->ID ) ) { $status_list[ wp_or_b2evo_item_status('deprecated', 'wp') ] = new xmlrpcval(T_('Deprecated')) ; } - if( $current_User->check_perm( 'blog_post!redirected', 'edit', false, $Blog->ID ) ) + if( check_user_perm( 'blog_post!redirected', 'edit', false, $Blog->ID ) ) { // Not supported by WP, maps to 'published' $status_list[ wp_or_b2evo_item_status('redirected', 'wp') ] = new xmlrpcval(T_('Redirected')) ; } @@ -481,7 +481,7 @@ function wp_getpostformats( $m ) foreach( $nopost_item_type_IDs as $ityp_ID => $ityp_usage ) { - if( ! $current_User->check_perm( 'blog_'.$ityp_usage, 'edit', false, $Blog->ID ) ) + if( ! check_user_perm( 'blog_'.$ityp_usage, 'edit', false, $Blog->ID ) ) { // No permission to use this post type: $exclude_posttype_IDs[] = $ityp_ID; } @@ -741,7 +741,7 @@ function wp_newcategory( $m ) return xmlrpcs_resperror(); } - if( ! $current_User->check_perm( 'blog_cats', '', false, $Blog->ID ) ) + if( ! check_user_perm( 'blog_cats', '', false, $Blog->ID ) ) { return xmlrpcs_resperror( 5, 'You are not allowed to add or edit categories in this blog.' ); } @@ -809,7 +809,7 @@ function wp_deletecategory( $m ) return xmlrpcs_resperror(); } - if( ! $current_User->check_perm( 'blog_cats', 'edit', false, $Blog->ID ) ) + if( ! check_user_perm( 'blog_cats', 'edit', false, $Blog->ID ) ) { // Permission denied return xmlrpcs_resperror( 5, 'You are not allowed to delete categories in this blog.' ); } @@ -885,7 +885,7 @@ function wp_getcommentstatuslist( $m ) } } - if( $current_User->check_perm('blog_comment!trash', '', false, $Blog->ID) ) + if( check_user_perm('blog_comment!trash', '', false, $Blog->ID) ) { $statuses[] = new xmlrpcval('trash'); } @@ -1207,7 +1207,7 @@ function wp_editcomment( $m ) return xmlrpcs_resperror(); } - if( ! $current_User->check_perm( 'comment!CURSTATUS', 'edit', false, $edited_Comment ) ) + if( ! check_user_perm( 'comment!CURSTATUS', 'edit', false, $edited_Comment ) ) { // Permission denied return xmlrpcs_resperror(3); } @@ -1273,7 +1273,7 @@ function wp_deletecomment( $m ) return xmlrpcs_resperror(); } - if( ! $current_User->check_perm( 'comment!CURSTATUS', 'delete', false, $edited_Comment ) ) + if( ! check_user_perm( 'comment!CURSTATUS', 'delete', false, $edited_Comment ) ) { // Permission denied return xmlrpcs_resperror(3); } diff --git a/inc/xmlrpc/model/_xmlrpcs.funcs.php b/inc/xmlrpc/model/_xmlrpcs.funcs.php index ceff8469733..d114a586e80 100644 --- a/inc/xmlrpc/model/_xmlrpcs.funcs.php +++ b/inc/xmlrpc/model/_xmlrpcs.funcs.php @@ -104,7 +104,7 @@ function _wp_mw_newmediaobject($m) } // CHECK PERMISSION: - if( ! $current_User->check_perm( 'files', 'add', false, $Blog->ID ) ) + if( ! check_user_perm( 'files', 'add', false, $Blog->ID ) ) { // Permission denied return xmlrpcs_resperror( 3 ); // User error 3 } @@ -450,7 +450,7 @@ function _wp_or_blogger_getusersblogs( $type, $m ) 'blogid' => new xmlrpcval( $l_blog_ID ), 'blogName' => new xmlrpcval( $l_Blog->get('shortname') ), 'url' => new xmlrpcval( $l_Blog->gen_blogurl() ), - 'isAdmin' => new xmlrpcval( $current_User->check_perm( 'blog_admin', 'edit', false, $l_Blog->ID ), 'boolean') ); + 'isAdmin' => new xmlrpcval( check_user_perm( 'blog_admin', 'edit', false, $l_Blog->ID ), 'boolean') ); if ( $type == 'wp') { $item['xmlrpc'] = new xmlrpcval ( $xmlsrv_url.'xmlrpc.php' ); @@ -1226,7 +1226,7 @@ function xmlrpcs_edit_comment( $params = array(), & $edited_Comment ) $edited_Comment_Item = $edited_Comment->get_Item(); $edited_Comment_Item->load_Blog(); - $perm_comment_edit = $current_User->check_perm( 'blog_comment!published', 'edit', false, $edited_Comment_Item->Blog->ID ); + $perm_comment_edit = check_user_perm( 'blog_comment!published', 'edit', false, $edited_Comment_Item->Blog->ID ); // CHECK HTML SANITY: // Following call says "WARNING: this does *NOT* (necessarilly) make the HTML code safe.": @@ -1356,7 +1356,7 @@ function xmlrpcs_new_item( $params, & $Blog = NULL ) * CHECK PERMISSION: (we need perm on all categories, especially if they are in different blogs) * NOTE: extra_cat_IDs array now includes main_cat_ID too, so we are actually checking ALL categories below */ - if( ! $current_User->check_perm( 'cats_post!'.$params['status'], 'edit', false, $params['extra_cat_IDs'] ) ) + if( ! check_user_perm( 'cats_post!'.$params['status'], 'edit', false, $params['extra_cat_IDs'] ) ) { // Permission denied return xmlrpcs_resperror( 3 ); // User error 3 } @@ -1372,7 +1372,7 @@ function xmlrpcs_new_item( $params, & $Blog = NULL ) $ItemType = & $ItemTypeCache->get_by_ID( $params['item_typ_ID'], false, false ); // Check permission for this post type - if( $ItemType && ! $current_User->check_perm( 'cats_item_type_'.$ItemType->perm_level, 'edit', false, $params['extra_cat_IDs'] ) ) + if( $ItemType && ! check_user_perm( 'cats_item_type_'.$ItemType->perm_level, 'edit', false, $params['extra_cat_IDs'] ) ) { // Permission denied return xmlrpcs_resperror( 3 ); // User error 3 } @@ -1507,7 +1507,7 @@ function xmlrpcs_edit_item( & $edited_Item, $params ) * CHECK PERMISSION: (we need perm on all categories, especially if they are in different blogs) * NOTE: extra_cat_IDs array now includes main_cat_ID too, so we are actually checking ALL categories below */ - if( ! $current_User->check_perm( 'cats_post!'.$params['status'], 'edit', false, $params['extra_cat_IDs'] ) ) + if( ! check_user_perm( 'cats_post!'.$params['status'], 'edit', false, $params['extra_cat_IDs'] ) ) { } } @@ -1523,7 +1523,7 @@ function xmlrpcs_edit_item( & $edited_Item, $params ) $ItemType = & $ItemTypeCache->get_by_ID( $params['item_typ_ID'], false, false ); // Check permission for this post type - if( $ItemType && ! $current_User->check_perm( 'cats_item_type_'.$ItemType->perm_level, 'edit', false, $params['extra_cat_IDs'] ) ) + if( $ItemType && ! check_user_perm( 'cats_item_type_'.$ItemType->perm_level, 'edit', false, $params['extra_cat_IDs'] ) ) { // Permission denied return xmlrpcs_resperror( 3 ); // User error 3 } @@ -1661,7 +1661,7 @@ function xmlrpcs_can_view_item( & $Item, & $current_User ) case 'protected': case 'draft': case 'deprecated': - $can_view_post = $current_User->check_perm( 'blog_ismember', 'view', false, $Item->get_blog_ID() ); + $can_view_post = check_user_perm( 'blog_ismember', 'view', false, $Item->get_blog_ID() ); break; case 'private': $can_view_post = ( $Item->creator_user_ID == $current_User->ID ); @@ -1753,8 +1753,6 @@ function xmlrpcs_check_cats( & $maincat, & $Blog, & $extracats ) */ function xmlrpc_get_items( $params, & $Blog ) { - global $current_User; - $params = array_merge( array( 'limit' => 0, 'item_ID' => 0, @@ -1764,7 +1762,7 @@ function xmlrpc_get_items( $params, & $Blog ) // Protected and private get checked by statuses_where_clause(). $statuses = array( 'published', 'redirected', 'protected', 'private' ); - if( $current_User->check_perm( 'blog_ismember', 'view', false, $Blog->ID ) ) + if( check_user_perm( 'blog_ismember', 'view', false, $Blog->ID ) ) { // These statuses require member status: $statuses = array_merge( $statuses, array( 'draft', 'deprecated' ) ); } @@ -1828,7 +1826,7 @@ function xmlrpc_get_items( $params, & $Blog ) */ function xmlrpc_get_comments( $params, & $Blog ) { - global $DB, $current_User; + global $DB; $params = array_merge( array( 'limit' => 0, @@ -1943,10 +1941,10 @@ function xmlrpc_get_comments( $params, & $Blog ) */ function xmlrpcs_delete_item( & $edited_Item ) { - global $current_User, $DB; + global $DB; // CHECK PERMISSION: - if( ! $current_User->check_perm( 'item_post!CURSTATUS', 'delete', false, $edited_Item ) ) + if( ! check_user_perm( 'item_post!CURSTATUS', 'delete', false, $edited_Item ) ) { // Permission denied return xmlrpcs_resperror( 3 ); // User error 3 } diff --git a/install/_functions_create.php b/install/_functions_create.php index 218f0a2f679..ea61607aa06 100644 --- a/install/_functions_create.php +++ b/install/_functions_create.php @@ -435,6 +435,11 @@ function create_default_data() 'usage' => 'post', 'use_short_title' => 'optional', ); + $post_types[] = array( + 'name' => 'Task', + 'allow_html' => 0, + 'front_order_workflow' => 20, + ); // Default settings: $post_type_default_settings = array( 'name' => '', @@ -467,6 +472,7 @@ function create_default_data() 'use_coordinates' => 'never', 'front_order_title' => 10, 'front_order_attachments' => 30, + 'front_order_workflow' => NULL, 'front_order_text' => 80, 'front_order_location' => 90, ); @@ -847,9 +853,9 @@ function create_default_data() task_begin( 'Creating default Post Statuses... ' ); - $post_status = array( 'New', 'In Progress', 'Duplicate', 'Not A Bug', 'In Review', 'Fixed', 'Closed', 'OK' ); - - $DB->query( "INSERT INTO T_items__status ( pst_name ) VALUES ( '".implode( "' ),( '", $post_status )." ')" ); + $post_status_with_order = array(" ( 'New', 10 ) ", " ( 'In Progress', 20 ) ", " ( 'Duplicate', 30 ) ", " ( 'Not A Bug', 40 ) ", " ( 'In Review', 50 ) ", " ( 'Fixed', 60 ) ", " ( 'Closed', 70 ) ", " ( 'OK', 80 ) ", ); + + $DB->query( "INSERT INTO T_items__status ( pst_name, pst_order ) VALUES ". implode( ",", $post_status_with_order ) ); task_end(); @@ -1584,8 +1590,8 @@ function create_demo_users() { // Impossible to rename the admin folder to another name // Display the errors: - echo get_install_format_text( ''.sprintf( 'ERROR: Impossible to rename %s to %s.', $src_admin_dir, $dest_admin_dir ).' ' ); - echo get_install_format_text( ''.sprintf( 'ERROR: Impossible to use "%s" for the admin account. Using "admin" instead.', $User_Admin->login ).' ' ); + echo get_install_format_text_and_log( ''.sprintf( 'ERROR: Impossible to rename %s to %s.', $src_admin_dir, $dest_admin_dir ).' ' ); + echo get_install_format_text_and_log( ''.sprintf( 'ERROR: Impossible to use "%s" for the admin account. Using "admin" instead.', $User_Admin->login ).' ' ); // Change admin login to "admin": $User_Admin->set( 'login', 'admin' ); @@ -1702,9 +1708,126 @@ function create_default_templates( $is_task = true ) 'item_details_revisions' => array( 'name' => 'Item Details: Small Print: Revisions', 'context' => 'item_details', - 'template' => 'Created by [author] • Last edit by [lastedit_user] on [mod_date|date_format=#extended_date] • [history_link] • [propose_change_link]' + 'template' => '[flag_icon] Created by [author] • Last edit by [lastedit_user] on [mod_date|date_format=#extended_date] [history_link|before=• ] [propose_change_link|before=• ]' + ), + 'item_details_author_details' => array( + 'name' => 'Item Details: Author Details', + 'context' => 'item_details', + 'template' => ' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Picture[User:picture|size=crop-top-128x128]
    Fullname[User:fullname]
    Last name[User:last_name]
    First name[User:first_name]
    Nickname[User:nick_name]
    Preferred name[User:preferred_name]
    ID[User:id]
    Login[User:login]
    Email[User:email]
    Micro bio[User:custom|field=microbio]
    Twitter[User:custom|field=twitter]
    Facebook[User:custom|field=facebook]
    LinkedIn[User:custom|field=linkedin]
    GitHub[User:custom|field=github]
    Website[User:custom|field=website|separator=
    ]
    ' + ), + + // Item attachments: + 'item_details_files_list' => array( + 'name' => 'Item Details: Attachments: List', + 'context' => 'item_details', + 'template' => '[files| + before=
      | + before_attach=
    • | + before_attach_size=(| + after_attach_size=)| + after_attach=
    • | + after=
    | + file_link_format=$file_name$| + display_download_icon=1| + file_link_text=title| + display_file_size=1| + display_file_desc=1| + ]' + ), + 'item_details_files_buttons' => array( + 'name' => 'Item Details: Attachments: Buttons', + 'context' => 'item_details', + 'template' => '[files| + before=| + before_attach=| + before_attach_size=(| + after_attach_size=)| + after_attach=| + after=| + attach_format=$file_link$| + file_link_format=$icon$ Download Now!
    $file_name$ $file_size$ $file_desc$| + display_download_icon=1| + file_link_text=title| + file_link_class=btn btn-success| + display_file_size=1| + display_file_desc=1| + ]' + ), + + // About Author widget: + 'about_author' => array( + 'name' => 'Item Details: About Author', + 'context' => 'item_details', + 'template' => '
    + [User:picture|size=crop-top-48x48] +
    +
    + [User:custom|field=microbio] +
    ', ), - // Content List widget: 'content_list' => array( @@ -1713,7 +1836,9 @@ function create_default_templates( $is_task = true ) 'template' => '[set:before_list=
      ] [set:after_list=
    ] [set:subcat_template=content_list_subcat] -[set:item_template=content_list_item]', +[set:item_template=content_list_item] +[set:crossposted_item_template=content_list_crossposted_item| // Use same as item_template] +[set:active_item_template=content_list_active_item| // Use same as item_template]', ), 'content_list_subcat' => array( 'name' => 'Content List: Subcat', @@ -1735,6 +1860,39 @@ function create_default_templates( $is_task = true ) excerpt_more_text=#more+arrow|excerpt_after_more=] ', ), + 'content_list_crossposted_item' => array( + 'name' => 'Content List: Crossposted Item', + 'context' => 'content_list_item', + 'template' => '
  • +

    [read_status] [Item:permalink|text=#fileicon+title|class=link] [flag_icon]

    [visibility_status] + [Item:excerpt| + before=
    | + after=
    | + excerpt_before_more=| + excerpt_more_text=#more+arrow|excerpt_after_more=] +
  • ', + ), + + // Content Title List: + 'content_title_list' => array( + 'name' => 'Content Title List', + 'context' => 'content_list_master', + 'template' => '[set:before_list=
      ] +[set:after_list=
    ] +[set:item_template=content_title_list_item] +[set:crossposted_item_template=| // Use same as item_template] +[set:active_item_template=content_title_list_active_item]', + ), + 'content_title_list_item' => array( + 'name' => 'Content Title List: Item', + 'context' => 'content_list_item', + 'template' => '
  • [Item:permalink|class=default|title=]
  • ', + ), + 'content_title_list_active_item' => array( + 'name' => 'Content Title List: Active Item', + 'context' => 'content_list_item', + 'template' => '
  • [Item:permalink|class=selected|title=]
  • ', + ), // Content Tiles style 1 (default): @@ -1745,6 +1903,8 @@ function create_default_templates( $is_task = true ) [set:after_list=
    ] [set:subcat_template=content_tiles_subcat| // Sub-template for displaying categories] [set:item_template=content_tiles_item| // Sub-template for displaying items] +[set:crossposted_item_template=| // Sub-template for displaying crossposted items] +[set:active_item_template=| // Sub-template for displaying active item] [set:rwd_cols=col-xs-12 col-sm-6 col-md-6 col-lg-4| // RWD classes for tile containers] [set:evo_tile__modifiers=evo_tile__md evo_tile__grey_bg evo_tile__hoverglow| // Modifier classes for each tile] [set:evo_tile_image__modifiers=| // Modifier classes for each tile image] @@ -1761,6 +1921,8 @@ function create_default_templates( $is_task = true ) [set:after_list=
    ] [set:subcat_template=content_tiles_subcat] [set:item_template=content_tiles_item] +[set:crossposted_item_template=| // Use same as item_template] +[set:active_item_template=| // Use same as item_template] [set:rwd_cols=col-xs-12 col-sm-6 col-md-6 col-lg-4] [set:evo_tile__modifiers=evo_tile__md evo_tile__grey_bg evo_tile__hoverglow] [set:evo_tile_image__modifiers=] @@ -1837,6 +1999,8 @@ function create_default_templates( $is_task = true ) [set:after_list=
    ] [set:subcat_template=content_tiles_btn_subcat] [set:item_template=content_tiles_btn_item] +[set:crossposted_item_template=| // Use same as item_template] +[set:active_item_template=| // Use same as item_template] [set:rwd_cols=col-xs-12 col-sm-6 col-md-6 col-lg-4] [set:evo_tile__modifiers=evo_tile__md evo_tile__grey_bg evo_tile__shadow] [set:evo_tile_image__modifiers=evo_tile_image__margin] @@ -1907,6 +2071,8 @@ function create_default_templates( $is_task = true ) [set:after_list=
    ] [set:subcat_template=content_tiles_bgimg_subcat] [set:item_template=content_tiles_bgimg_item] +[set:crossposted_item_template=| // Use same as item_template] +[set:active_item_template=| // Use same as item_template] [set:rwd_cols=col-xs-12 col-sm-6 col-md-6 col-lg-4] [set:evo_tile__modifiers=evo_tile__md evo_tile__grey_bg evo_tile__square evo_tile__shadow] [set:evo_tile_image__modifiers=] @@ -2126,6 +2292,8 @@ function create_default_templates( $is_task = true ) 'template' => '[set:before_list=
    ] [set:after_list=
    ] [set:item_template=content_tabs_item] +[set:crossposted_item_template=| // Use same as item_template] +[set:active_item_template=| // Use same as item_template] [set:rwd_header_col=col-sm-5 col-xs-12] [set:rwd_text_col=col-sm-5 col-xs-12] [set:rwd_image_col=col-sm-7 pull-right-sm col-xs-12] @@ -2221,7 +2389,7 @@ class=btn btn-default| [set:reg1_template=registration_email_social] [set:reg1_required=email] -[set:reg2_template=registration_step2] +[set:reg2_template=registration_step2| // Page 2 is not implemented yet] [set:reg2_required=firstname] ', ), @@ -2241,7 +2409,7 @@ class=btn btn-primary btn-lg| class=btn btn-default| text=Already have an account... ?]
    -[Plugin:evo_sociallogin| // This should call the SkinTag of plugin with given code +[Plugin:evo_sociallogin| // Call the SkinTag of the plugin before=] ', @@ -2382,6 +2550,45 @@ class=btn btn-primary btn-lg|
    [echo:tag_post_count] posts are tagged with "[Tag:name]"
    ', + ), + + 'content_list_with_thumbnail' => array( + 'name' => 'Content List with Thumbnail', + 'context' => 'content_list_master', + 'template' => '[set:before_list=
      ] +[set:after_list=
    ] +[set:item_template=content_list_with_thumbnail_item| // Sub-template for displaying items] +[set:crossposted_item_template=| // Sub-template for displaying crossposted items] +[set:active_item_template=| // Sub-template for displaying active item] +[set:evo_thumblist_image__modifiers=| // Modifier classes for each thumbnail image] +[set:evo_thumblist_image__size=crop-80x80| // Image size for displaying image]', + ), + + 'content_list_with_thumbnail_item' => array( + 'name' => 'Content List with Thumbnail: Item', + 'context' => 'content_list_item', + 'template' => '
  • +
    + [Item:images| + restrict_to_image_position=#cover_and_teaser_all| // Priority to cover image, fall back to any teaser image + limit=1| // Max 1 images + image_size=$evo_thumblist_image__size$| + image_link_to=single| // Link to item details + placeholder=#file_thumbnail_text_icon| // If no image available, display text file icon + ] +
    +
    + [Item:permalink|text=#title|class=default] +
    +
    +

    [Item:excerpt| + excerpt_no_more_link=| // No "more" link + max_words=20| // how many words we will display + ] +

    + [Item:permalink|text=...|class=btn btn-default evo_thumblist_button evo_thumblist_button__transparent|title=] +
    +
  • ', ) ); diff --git a/install/_functions_delete.php b/install/_functions_delete.php index 4c4f58313fb..31f153fa466 100644 --- a/install/_functions_delete.php +++ b/install/_functions_delete.php @@ -17,12 +17,12 @@ function db_delete() { global $DB, $db_config, $tableprefix; - echo get_install_format_text( "Disabling foreign key checks...
    \n", 'br' ); + echo get_install_format_text_and_log( "Disabling foreign key checks...
    \n", 'br' ); $DB->query( 'SET FOREIGN_KEY_CHECKS=0' ); foreach( $db_config['aliases'] as $alias => $tablename ) { - echo get_install_format_text( "Dropping $tablename table...
    \n", 'br' ); + echo get_install_format_text_and_log( "Dropping $tablename table...
    \n", 'br' ); evo_flush(); $DB->query( 'DROP TABLE IF EXISTS '.$tablename ); } @@ -31,7 +31,7 @@ function db_delete() $remaining_tables = $DB->get_col( 'SHOW TABLES FROM `'.$db_config['name'].'` LIKE "'.$tableprefix.'%"' ); foreach( $remaining_tables as $tablename ) { - echo get_install_format_text( "Dropping $tablename table...
    \n", 'br' ); + echo get_install_format_text_and_log( "Dropping $tablename table...
    \n", 'br' ); evo_flush(); $DB->query( 'DROP TABLE IF EXISTS '.$tablename ); } @@ -76,6 +76,6 @@ function uninstall_b2evolution() /* REMOVE DATABASE */ db_delete(); - echo get_install_format_text( '

    '.T_('Reset done!').'

    ', 'p' ); + echo get_install_format_text_and_log( '

    '.T_('Reset done!').'

    ', 'p' ); } ?> \ No newline at end of file diff --git a/install/_functions_evoupgrade.php b/install/_functions_evoupgrade.php index 0aab728a0e9..8dff799f6af 100644 --- a/install/_functions_evoupgrade.php +++ b/install/_functions_evoupgrade.php @@ -28,7 +28,7 @@ function set_upgrade_checkpoint( $version ) global $recreate_autogenerated_excerpts; - echo get_install_format_text( 'Creating DB schema version checkpoint at '.$version.'... ' ); + echo get_install_format_text_and_log( 'Creating DB schema version checkpoint at '.$version.'... ' ); if( $version < 8060 ) { @@ -45,7 +45,7 @@ function set_upgrade_checkpoint( $version ) $elapsed_time = time() - $script_start_time; - echo get_install_format_text( "OK. (Elapsed upgrade time: $elapsed_time seconds)
    \n", 'br' ); + echo get_install_format_text_and_log( "OK. (Elapsed upgrade time: $elapsed_time seconds)

    \n", 'br' ); // Update the progress bar status update_install_progress_bar(); @@ -57,7 +57,7 @@ function set_upgrade_checkpoint( $version ) { // Max exe time not disabled and we're recahing the end $upgrade_action = ( $action == 'auto_upgrade' ) ? $action : 'evoupgrade'; $recreate_excerpts = $recreate_autogenerated_excerpts ? '&recreate_excerpts=1' : ''; - echo get_install_format_text( 'We are reaching the time limit for this script. Please click continue...' ); + echo get_install_format_text_and_log( 'We are reaching the time limit for this script. Please click continue...' ); // Dirty temporary solution: exit(0); } @@ -461,7 +461,7 @@ function convert_lang_to_locale( $table, $columnlang, $columnID ) $default_locale = 'en-EU'; } - echo get_install_format_text( 'Converting langs to locales for '. $table. '...
    ', 'br' ); + echo get_install_format_text_and_log( 'Converting langs to locales for '. $table. '...
    ', 'br' ); // query given languages in $table $query = "SELECT $columnID, $columnlang FROM $table"; @@ -475,11 +475,11 @@ function convert_lang_to_locale( $table, $columnlang, $columnID ) foreach( $languagestoconvert as $lkey => $lIDs) { // converting the languages we've found $converted = false; - echo get_install_format_text( '  Converting lang \''. $lkey. '\' ' ); // (with IDs: '. implode( ', ', $lIDs ). ').. '; + echo get_install_format_text_and_log( '  Converting lang \''. $lkey. '\' ' ); // (with IDs: '. implode( ', ', $lIDs ). ').. '; if( preg_match('/[a-z]{2}-[A-Z]{2}(-.{1,14})?/', $lkey) ) { // Already valid - echo get_install_format_text( 'nothing to update, already valid!
    ', 'br' ); + echo get_install_format_text_and_log( 'nothing to update, already valid!
    ', 'br' ); continue; } @@ -494,7 +494,7 @@ function convert_lang_to_locale( $table, $columnlang, $columnID ) UPDATE $table SET $columnlang = '$newlkey' WHERE $columnlang = '$lkey'" ); - echo get_install_format_text( 'to locale \''. $newlkey. '\'
    ', 'br' ); + echo get_install_format_text_and_log( 'to locale \''. $newlkey. '\'
    ', 'br' ); break; } } @@ -505,7 +505,7 @@ function convert_lang_to_locale( $table, $columnlang, $columnID ) $DB->query( "UPDATE $table SET $columnlang = '$default_locale' WHERE $columnlang = '$lkey'" ); - echo get_install_format_text( 'forced to default locale \''. $default_locale. '\'
    ', 'br' ); + echo get_install_format_text_and_log( 'forced to default locale \''. $default_locale. '\'
    ', 'br' ); } } echo "\n"; @@ -627,12 +627,12 @@ function upgrade_b2evo_tables( $upgrade_action = 'evoupgrade' ) // Force MySQL strict mode: $DB->query( 'SET sql_mode = ""', 'REMOVE MySQL "strict" mode in order not to worry about missing defaults until the end of the upgrade.' ); - echo get_install_format_text( '

    '.T_('Checking DB schema version...').' ', 'p-start' ); + echo get_install_format_text_and_log( '

    '.T_('Checking DB schema version...').' ', 'p-start' ); $old_db_version = get_db_version(); if( empty($old_db_version) ) { - echo get_install_format_text( '

    OOPS! b2evolution doesn\'t seem to be installed yet.

    ', 'p' ); + echo get_install_format_text_and_log( '

    OOPS! b2evolution doesn\'t seem to be installed yet.

    ', 'p' ); return false; } @@ -640,7 +640,7 @@ function upgrade_b2evo_tables( $upgrade_action = 'evoupgrade' ) if( $old_db_version < 8000 ) debug_die( T_('This version is too old!') ); if( $old_db_version > $new_db_version ) debug_die( T_('This version is too recent! We cannot downgrade to the version you are trying to install...') ); - echo get_install_format_text( "OK.
    \n", 'br' ); + echo get_install_format_text_and_log( "OK.
    \n", 'br' ); if( $old_db_version < 8010 ) { @@ -2256,8 +2256,6 @@ function install_basic_widgets_9408() */ global $DB; - load_funcs( 'widgets/_widgets.funcs.php' ); - $blog_ids = $DB->get_assoc( 'SELECT blog_ID, "std" FROM T_blogs' ); foreach( $blog_ids as $blog_id => $blog_type ) @@ -7490,7 +7488,7 @@ function add_basic_widget_11670( $blog_ID, $container_name, $code, $type, $order $skin_chicago_path = $adminskins_path.'chicago/'; if( file_exists( $skin_chicago_path ) && ! rmdir_r( $skin_chicago_path ) ) { // Display a warning if no permissions to delete the skin folder: - echo get_install_format_text( '' + echo get_install_format_text_and_log( '' .'WARNING: the Chicago admin skin is no longer supported. Please delete the folder '.$skin_chicago_path.'' .'' ); } @@ -10369,7 +10367,7 @@ function add_basic_widget_12990( $blog_ID, $container_name, $code, $type, $order // Disable plugin if new data file cannot be downloaded as expected: $status_result = $geoip_Plugin->set_status( 'needs_config' ); // Display error message: - echo get_install_format_text( '' + echo get_install_format_text_and_log( '' .'UNEXPECTED ERROR: '.nl2br( $ex->getMessage() ) .( $status_result ? ' WARNING: The plugin #'.$geoip_Plugin->ID.'('.$geoip_Plugin->name.') has been disabled!' : '' ) .'
    Please check the GeoIP plugin settings right after this upgrade has finished.' @@ -12188,7 +12186,7 @@ function upg_convert_plugin_coll_checkbox_settings( $plugin_classname, $setting_ { if( $loop_Plugin = & $admin_Plugins->get_by_classname( $plugin_class ) ) { - echo get_install_format_text( sprintf( '' + echo get_install_format_text_and_log( sprintf( '' .'The plugin %s is no longer updated by b2evolution v7. ' .'You may obtain new versions from the plugin repository.' .'', @@ -12209,7 +12207,7 @@ function upg_convert_plugin_coll_checkbox_settings( $plugin_classname, $setting_ else { $plugin_deleted = false; - echo get_install_format_text( sprintf( 'Unable to delete directory: %s', $plugin_dir )."
    \n", 'br' ); + echo get_install_format_text_and_log( sprintf( 'Unable to delete directory: %s', $plugin_dir )."
    \n", 'br' ); } } if( file_exists( $plugin_filename ) && is_file( $plugin_filename ) ) @@ -12221,7 +12219,7 @@ function upg_convert_plugin_coll_checkbox_settings( $plugin_classname, $setting_ else { $plugin_deleted = false; - echo get_install_format_text( sprintf( 'Unable to delete file: %s', $plugin_filename )."
    \n", 'br' ); + echo get_install_format_text_and_log( sprintf( 'Unable to delete file: %s', $plugin_filename )."
    \n", 'br' ); } } if( $plugin_deleted ) @@ -12552,7 +12550,7 @@ function upg_convert_plugin_coll_checkbox_settings( $plugin_classname, $setting_ { if( $obsolete_Skin = $SkinCache->get_by_class( $skin_class, false, false ) ) { // Installed skin, display a warning: - echo get_install_format_text( sprintf( '' + echo get_install_format_text_and_log( sprintf( '' .'The skin %s is no longer updated by b2evolution v7. You may obtain new versions from the skin repository' .'', ''.$obsolete_Skin->get_default_name().'', 'https://skins.b2evolution.net/' )."
    \n", 'br' ); @@ -12573,7 +12571,7 @@ function upg_convert_plugin_coll_checkbox_settings( $plugin_classname, $setting_ if( ! rmdir_r( $skins_path.$folder ) ) { $folders_deleted = false; - echo get_install_format_text( sprintf( 'Unable to delete folder %s.', $skins_path.$folder ) ); + echo get_install_format_text_and_log( sprintf( 'Unable to delete folder %s.', $skins_path.$folder ) ); } } } @@ -12597,11 +12595,6 @@ function upg_convert_plugin_coll_checkbox_settings( $plugin_classname, $setting_ upg_task_end(); } - if( upg_task_start( 16011, 'Dummy upgrade block, just to force execution of the upgrade procedure to update templates for Search Results...' ) ) - { // part of 7.1.5-stable - upg_task_end(); - } - if( upg_task_start( 16012, 'Updating site skins...' ) ) { // part of 7.1.5-stable $SQL = new SQL( 'Get site skins for update "Grouping" setting' ); @@ -12656,6 +12649,396 @@ function upg_convert_plugin_coll_checkbox_settings( $plugin_classname, $setting_ upg_task_end(); } + if( upg_task_start( 16083, 'Upgrading table for Menu entries and Converting menu widgets "Messaging", "Flagged Items" and "My Profile" into "Basic Menu link" widget...' ) ) + { // part of 7.2 + db_upgrade_cols( 'T_menus__entry', array( + 'ADD' => array( + 'ment_user_pic_size' => 'VARCHAR(32) COLLATE ascii_general_ci NULL AFTER ment_order', + 'ment_access' => 'ENUM( "any", "loggedin", "perms" ) COLLATE ascii_general_ci NOT NULL DEFAULT "perms" AFTER ment_visibility', + 'ment_show_badge' => 'TINYINT(1) NOT NULL DEFAULT 1 AFTER ment_access', + 'ment_hide_empty' => 'TINYINT(1) NOT NULL DEFAULT 0', + ), + ) ); + // Convert menu widgets "Messaging", "Flagged Items" and "My Profile" into "Basic Menu link" widget: + // (update to proper param 'link_type' because these widgets had no this param before) + $menu_widgets_SQL = new SQL( 'Get menu widgets before converting' ); + $menu_widgets_SQL->SELECT( 'wi_ID, wi_code, wi_params' ); + $menu_widgets_SQL->FROM( 'T_widget__widget' ); + $menu_widgets_SQL->WHERE( 'wi_code IN ( "msg_menu_link", "flag_menu_link", "profile_menu_link" )' ); + $menu_widgets = $DB->get_results( $menu_widgets_SQL ); + foreach( $menu_widgets as $menu_widget ) + { + $menu_widget_params = empty( $menu_widget->wi_params ) ? array() : unserialize( $menu_widget->wi_params ); + if( $menu_widget->wi_code == 'msg_menu_link' ) + { + if( ! isset( $menu_widget_params['link_type'] ) ) + { // Link type may be not set yet: + $menu_widget_params['link_type'] = 'messages'; + } + } + elseif( $menu_widget->wi_code == 'flag_menu_link' ) + { + $menu_widget_params['link_type'] = 'flagged'; + } + else + { + $menu_widget_params['link_type'] = 'myprofile'; + if( empty( $menu_widget_params['profile_picture_size'] ) ) + { // Sset default picture profile size if it was not set yet: + $menu_widget_params['profile_picture_size'] = 'crop-top-15x15'; + } + } + $DB->query( 'UPDATE T_widget__widget + SET wi_code = "basic_menu_link", + wi_params = '.$DB->quote( serialize( $menu_widget_params ) ).' + WHERE wi_ID = '.$menu_widget->wi_ID ); + } + upg_task_end(); + } + + if( upg_task_start( 16084, 'Upgrading items type table...' ) ) + { // part of 7.2 + db_add_col( 'T_items__type', 'ityp_front_order_workflow', 'SMALLINT(6) NULL DEFAULT NULL AFTER ityp_front_order_attachments' ); + upg_task_end(); + } + + if( upg_task_start( 16085, 'Creating default item type "Task"...' ) ) + { // part of 7.2 + $SQL = new SQL( 'Check at least one item type with name "Task" for existence' ); + $SQL->SELECT( 'ityp_ID' ); + $SQL->FROM( 'T_items__type' ); + $SQL->WHERE( 'ityp_name = "Task"' ); + $SQL->LIMIT( 1 ); + if( ! $DB->get_var( $SQL ) ) + { // Create one default item type "Task": + $r = $DB->query( 'INSERT INTO T_items__type ( ityp_name, ityp_usage, ityp_template_name, ityp_allow_html, ityp_front_order_title, ityp_front_order_attachments, ityp_front_order_workflow, ityp_front_order_text, ityp_front_order_location ) + VALUES ( "Task", "post", "single", 0, 10, 30, 20, 80, 90 )' ); + if( $r && $DB->insert_id > 0 ) + { // Enable new created item type all forum and tracker: + $DB->query( 'INSERT INTO T_items__type_coll ( itc_ityp_ID, itc_coll_ID ) + SELECT '.$DB->insert_id.', blog_ID + FROM T_blogs + WHERE blog_type IN ( "forum", "group" )' ); + } + } + upg_task_end(); + } + + if( upg_task_start( 16086, 'Upgrading item status table...' ) ) + { // part of 7.2 + db_add_col( 'T_items__status', 'pst_order', 'INT(11) NULL DEFAULT NULL' ); + upg_task_end(); + } + + if( upg_task_start( 16087, 'Upgrading item status table...' ) ) + { // part of 7.2 + $DB->query( 'UPDATE T_items__status SET pst_order = 10 WHERE pst_name = "New"' ); + $DB->query( 'UPDATE T_items__status SET pst_order = 20 WHERE pst_name = "In Progress"' ); + $DB->query( 'UPDATE T_items__status SET pst_order = 30 WHERE pst_name = "Duplicate"' ); + $DB->query( 'UPDATE T_items__status SET pst_order = 40 WHERE pst_name = "Not A Bug"' ); + $DB->query( 'UPDATE T_items__status SET pst_order = 50 WHERE pst_name = "In Review"' ); + $DB->query( 'UPDATE T_items__status SET pst_order = 60 WHERE pst_name = "Fixed"' ); + $DB->query( 'UPDATE T_items__status SET pst_order = 70 WHERE pst_name = "Closed"' ); + $DB->query( 'UPDATE T_items__status SET pst_order = 80 WHERE pst_name = "OK"' ); + upg_task_end(); + } + + if( upg_task_start( 16088, 'Converting widget "Common Navigation Links" into "Embed Menu" widget...' ) ) + { // part of 7.2 + $nav_widgets_SQL = new SQL( 'Get widgets "Common Navigation Links" before converting' ); + $nav_widgets_SQL->SELECT( 'wi_ID, wi_params' ); + $nav_widgets_SQL->FROM( 'T_widget__widget' ); + $nav_widgets_SQL->WHERE( 'wi_code = "coll_common_links"' ); + $nav_widgets = $DB->get_assoc( $nav_widgets_SQL ); + if( ! empty( $nav_widgets ) ) + { // If at least one widget "Common Navigation Links" is found: + load_class( 'menus/model/_sitemenu.class.php', 'SiteMenu' ); + load_class( 'menus/model/_sitemenuentry.class.php', 'SiteMenuEntry' ); + // widget_param_key => array( menu_entry_type, menu_entry_text ): + $nav_menu_entries = array( + 'show_home' => array( 'home', T_('Home') ), + 'show_recently' => array( 'recentposts', T_('Recently') ), + 'show_search' => array( 'search', T_('Search') ), + 'show_postidx' => array( 'postidx', T_('Post index') ), + 'show_archives' => array( 'arcdir', T_('Archives') ), + 'show_categories' => array( 'catdir', T_('Categories') ), + 'show_mediaidx' => array( 'mediaidx', T_('Photo index') ), + 'show_latestcomments' => array( 'latestcomments', T_('Latest comments') ), + 'show_owneruserinfo' => array( 'owneruserinfo', T_('Owner details') ), + 'show_ownercontact' => array( 'ownercontact', T_('Contact') ), + 'show_sitemap' => array( 'sitemap', T_('Site map') ), + ); + foreach( $nav_widgets as $nav_widget_ID => $nav_widget_params ) + { + $nav_widget_params = empty( $nav_widget_params ) ? array() : unserialize( $nav_widget_params ); + + if( empty( $nav_widget_params ) ) + { // Set default params: + $nav_widget_params = array( + 'show_home' => 1, + 'show_recently' => 1, + 'show_archives' => 1, + 'show_categories' => 1, + 'show_latestcomments' => 1, + ); + } + + // Create Menu for converting Widget: + $nav_SiteMenu = new SiteMenu(); + $nav_SiteMenu->set( 'name', 'Common Navigation Links #'.$nav_widget_ID ); + $nav_SiteMenu->dbinsert(); + $menu_entry_order = 10; + foreach( $nav_menu_entries as $nav_widget_param => $nav_menu_entry_data ) + { + if( empty( $nav_widget_params[ $nav_widget_param ] ) ) + { // Skip not enabled menu entry in old widget: + continue; + } + // Create only enabled menu entries: + $nav_SiteMenuEntry = new SiteMenuEntry(); + $nav_SiteMenuEntry->set( 'menu_ID', $nav_SiteMenu->ID ); + $nav_SiteMenuEntry->set( 'type', $nav_menu_entry_data[0] ); + $nav_SiteMenuEntry->set( 'text', $nav_menu_entry_data[1] ); + $nav_SiteMenuEntry->set( 'order', $menu_entry_order ); + $nav_SiteMenuEntry->dbinsert(); + $menu_entry_order += 10; + + // Remove old widget param: + unset( $nav_widget_params[ $nav_widget_param ] ); + } + + // Use new created Menu to converting widget: + $nav_widget_params['menu_ID'] = $nav_SiteMenu->ID; + // Old widget used only list mode: + $nav_widget_params['display_mode'] = 'list'; + + // Update widget to new params: + $DB->query( 'UPDATE T_widget__widget + SET wi_code = "embed_menu", + wi_params = '.$DB->quote( serialize( $nav_widget_params ) ).' + WHERE wi_ID = '.$nav_widget_ID ); + } + } + upg_task_end(); + } + + if( upg_task_start( 16089, 'Converting widget "User Tools" into "Embed Menu" widget...' ) ) + { // part of 7.2 + $nav_widgets_SQL = new SQL( 'Get widgets "User Tools" before converting' ); + $nav_widgets_SQL->SELECT( 'wi_ID, wi_params' ); + $nav_widgets_SQL->FROM( 'T_widget__widget' ); + $nav_widgets_SQL->WHERE( 'wi_code = "user_tools"' ); + $nav_widgets = $DB->get_assoc( $nav_widgets_SQL ); + if( ! empty( $nav_widgets ) ) + { // If at least one widget "User Tools" is found: + load_class( 'menus/model/_sitemenu.class.php', 'SiteMenu' ); + load_class( 'menus/model/_sitemenuentry.class.php', 'SiteMenuEntry' ); + // widget_param_key => array( menu_entry_type, widget_param_for_text, {widget_param_for_show_badge} ): + $nav_menu_entries = array( + 'user_postnew_link_show' => array( 'postnew', 'user_postnew_link' ), + 'user_messaging_link_show' => array( 'messages', 'user_messaging_link', 'show_badge' ), + 'user_contacts_link_show' => array( 'contacts', 'user_contacts_link' ), + 'user_view_link_show' => array( 'myprofile', 'user_view_link' ), + 'user_profile_link_show' => array( 'profile', 'user_profile_link' ), + 'user_picture_link_show' => array( 'avatar', 'user_picture_link' ), + 'user_password_link_show' => array( 'password', 'user_password_link' ), + 'user_preferences_link_show' => array( 'userprefs', 'user_preferences_link' ), + 'user_subs_link_show' => array( 'usersubs', 'user_subs_link' ), + 'user_admin_link_show' => array( 'admin', 'user_admin_link' ), + 'user_logout_link_show' => array( 'logout', 'user_logout_link' ), + ); + foreach( $nav_widgets as $nav_widget_ID => $nav_widget_params ) + { + $nav_widget_params = empty( $nav_widget_params ) ? array() : unserialize( $nav_widget_params ); + + if( empty( $nav_widget_params ) ) + { // Set default params: + $nav_widget_params = array( + 'title' => T_('User tools'), + 'user_postnew_link_show' => 1, + 'user_postnew_link' => T_('Write a new post...'), + 'user_messaging_link_show' => 1, + 'show_badge' => 1, + 'user_messaging_link' => T_('My messages'), + 'user_contacts_link_show' => 1, + 'user_contacts_link' => T_('My contacts'), + 'user_view_link_show' => 1, + 'user_view_link' => T_('My profile'), + 'user_profile_link_show' => 1, + 'user_profile_link' => T_('Edit my profile'), + 'user_picture_link_show' => 1, + 'user_picture_link' => T_('Change my picture'), + 'user_admin_link_show' => 1, + 'user_admin_link' => T_('Admin area'), + 'user_logout_link_show' => 1, + 'user_logout_link' => T_('Log out'), + ); + } + + // Create Menu for converting Widget: + $nav_SiteMenu = new SiteMenu(); + $nav_SiteMenu->set( 'name', 'User Tools #'.$nav_widget_ID ); + $nav_SiteMenu->dbinsert(); + $menu_entry_order = 10; + foreach( $nav_menu_entries as $nav_widget_param => $nav_menu_entry_data ) + { + if( empty( $nav_widget_params[ $nav_widget_param ] ) ) + { // Skip not enabled menu entry in old widget: + continue; + } + // Create only enabled menu entries: + $nav_SiteMenuEntry = new SiteMenuEntry(); + $nav_SiteMenuEntry->set( 'menu_ID', $nav_SiteMenu->ID ); + $nav_SiteMenuEntry->set( 'type', $nav_menu_entry_data[0] ); + if( isset( $nav_widget_params[ $nav_menu_entry_data[1] ] ) ) + { // Set text for menu entry: + $nav_SiteMenuEntry->set( 'text', $nav_widget_params[ $nav_menu_entry_data[1] ] ); + // Remove old widget param: + unset( $nav_widget_params[ $nav_menu_entry_data[1] ] ); + } + if( isset( $nav_menu_entry_data[2], $nav_widget_params[ $nav_menu_entry_data[2] ] ) ) + { // Set "Show Badge" for menu entry: + $nav_SiteMenuEntry->set( 'show_badge', $nav_widget_params[ $nav_menu_entry_data[2] ] ); + // Remove old widget param: + unset( $nav_widget_params[ $nav_menu_entry_data[2] ] ); + } + $nav_SiteMenuEntry->set( 'order', $menu_entry_order ); + $nav_SiteMenuEntry->dbinsert(); + $menu_entry_order += 10; + + // Remove old widget param: + unset( $nav_widget_params[ $nav_widget_param ] ); + } + + // Use new created Menu to converting widget: + $nav_widget_params['menu_ID'] = $nav_SiteMenu->ID; + // Old widget used only list mode: + $nav_widget_params['display_mode'] = 'list'; + + // Update widget to new params: + $DB->query( 'UPDATE T_widget__widget + SET wi_code = "embed_menu", + wi_params = '.$DB->quote( serialize( $nav_widget_params ) ).' + WHERE wi_ID = '.$nav_widget_ID ); + } + } + upg_task_end(); + } + + if( upg_task_start( 16090, 'Installing new widget container "Site Map"...' ) ) + { // part of 7.2 + install_new_default_widgets( 'sitemap' ); + upg_task_end(); + } + + if( upg_task_start( 16102, 'Upgrading columns to utf8mb4_bin...' ) ) + { // part of 7.2 + // NOTE: This is a duplicate block of 16014 because auto-upgrade tool cannot detect differences in COLLATE: + // Remove keyphrases with length > 250 chars before reducing column size in order to avoid duplicate entry errors: + $DB->query( 'DELETE FROM T_track__keyphrase + WHERE LENGTH( keyp_phrase ) > 250' ); + $DB->query( 'UPDATE T_hitlog + SET hit_keyphrase = NULL + WHERE LENGTH( hit_keyphrase ) > 250' ); + // Drop unique key before changing column to utf8mb4(4bytes) from utf8(3bytes), + // because max size for unique key is 1000 bytes(4bytes * 250chars): + db_drop_index( 'T_track__keyphrase', 'keyp_phrase' ); + // Remove all duplicated key phrases which may were inserted by miskate when INDEX KEY for keyp_phrase was not UNIQUE: + $dupl_keyphrases_SQL = new SQL( 'Find all duplicated key phrases' ); + $dupl_keyphrases_SQL->SELECT( 'keyp_phrase, GROUP_CONCAT( keyp_ID ) AS IDs, + SUM( keyp_count_refered_searches ) AS sum_keyp_count_refered_searches, + SUM( keyp_count_internal_searches ) AS sum_keyp_count_internal_searches' ); + $dupl_keyphrases_SQL->FROM( 'T_track__keyphrase' ); + $dupl_keyphrases_SQL->GROUP_BY( 'keyp_phrase' ); + $dupl_keyphrases_SQL->HAVING( 'COUNT( keyp_phrase ) > 1' ); + $dupl_keyphrases = $DB->get_results( $dupl_keyphrases_SQL ); + foreach( $dupl_keyphrases as $dupl_keyphrase ) + { + // Find first/min record because only this is correct and only this can be kept in DB: + // (All next duplicates must be removed from DB) + $first_keyp_ID = min( explode( ',', $dupl_keyphrase->IDs ) ); + // Fix counters by moving all what counted in duplicated records by mistake: + $DB->query( 'UPDATE T_track__keyphrase + SET keyp_count_refered_searches = '.$dupl_keyphrase->sum_keyp_count_refered_searches.', + keyp_count_internal_searches = '.$dupl_keyphrase->sum_keyp_count_internal_searches.' + WHERE keyp_ID = '.$first_keyp_ID ); + // Delete all duplicated/wrong records except of only first/correct: + $DB->query( 'DELETE FROM T_track__keyphrase + WHERE keyp_ID IN ( '.$dupl_keyphrase->IDs.' ) + AND keyp_ID != '.$first_keyp_ID ); + } + // Upgrade key phrase columns: + db_modify_col( 'T_track__keyphrase', 'keyp_phrase', 'VARCHAR( 250 ) COLLATE utf8mb4_bin NOT NULL' ); + db_add_index( 'T_track__keyphrase', 'keyp_phrase', 'keyp_phrase', 'UNIQUE' ); + db_modify_col( 'T_hitlog', 'hit_keyphrase', 'VARCHAR(250) COLLATE utf8mb4_bin DEFAULT NULL' ); + // Modify these columns in order to avoid errors when 4bytes char is in search string: + db_modify_col( 'T_items__tag', 'tag_name', 'VARCHAR(50) COLLATE utf8mb4_bin NOT NULL' ); + db_modify_col( 'T_files', 'file_path', 'varchar(767) COLLATE utf8mb4_bin not null default ""' ); + upg_task_end(); + } + + if( upg_task_start( 16110, 'Creating table for checklist lines...' ) ) + { // part of 7.2 + db_create_table( 'T_items__checklist_lines', ' + check_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + check_item_ID INT(10) UNSIGNED NOT NULL, + check_checked TINYINT(1) NOT NULL DEFAULT 0, + check_label VARCHAR( 10000 ) COLLATE utf8mb4_unicode_ci NOT NULL, + check_order INT(11) NOT NULL DEFAULT 1, + PRIMARY KEY (check_ID), + KEY check_item_ID (check_item_ID)' ); + upg_task_end(); + } + + if( upg_task_start( 16130, 'Installing new widgets/containers...' ) ) + { // part of 7.2.0-beta + install_new_default_widgets( 'comment_list', 'request_title' ); + upg_task_end(); + } + + if( upg_task_start( 16140, 'Installing new widget title for search page and updating widget "Search Form"...' ) ) + { // part of 7.2.0-beta + // Add widget CSS class for all search form widgets that use full form template: + $search_widgets_SQL = new SQL( 'Get widgets "Search Form" before updating params' ); + $search_widgets_SQL->SELECT( 'wi_ID, wi_params' ); + $search_widgets_SQL->FROM( 'T_widget__widget' ); + $search_widgets_SQL->WHERE( 'wi_code = "coll_search_form"' ); + $search_widgets_SQL->WHERE_and( 'wi_params IS NOT NULL' ); + $search_widgets = $DB->get_assoc( $search_widgets_SQL ); + foreach( $search_widgets as $search_widget_ID => $search_widget_params ) + { + $search_widget_params = unserialize( $search_widget_params ); + if( isset( $search_widget_params['template'] ) && + $search_widget_params['template'] == 'search_form_full' ) + { // Add class "well" only for full form: + $search_widget_params['widget_css_class'] = isset( $search_widget_params['widget_css_class'] ) ? trim( $search_widget_params['widget_css_class'].' well' ) : 'well'; + $DB->query( 'UPDATE T_widget__widget + SET wi_params = '.$DB->quote( serialize( $search_widget_params ) ).' + WHERE wi_ID = '.$search_widget_ID ); + } + } + // Add new default widget for title on search page: + install_new_default_widgets( 'search_area', 'request_title' ); + upg_task_end(); + } + + if( upg_task_start( 16150, 'Installing new widgets for container "Item List"...' ) ) + { // part of 7.2.0-beta + install_new_default_widgets( 'item_list', 'request_title' ); + upg_task_end(); + } + + if( upg_task_start( 16160, 'Dummy upgrade block, just to force execution of the upgrade procedure to update templates for cross-posted items...' ) ) + { // part of 7.2.0-beta + upg_task_end(); + } + + if( upg_task_start( 16170, 'Upgrading menu entries table...') ) + { // part of 7.2.1-beta + db_add_col( 'T_menus__entry', 'ment_class', 'VARCHAR(128) COLLATE ascii_general_ci NULL' ); + upg_task_end(); + } + /* * ADD UPGRADES __ABOVE__ IN A NEW UPGRADE BLOCK. * @@ -12683,7 +13066,7 @@ function upg_convert_plugin_coll_checkbox_settings( $plugin_classname, $setting_ { // We haven't executed these general tasks yet: // Update modules own b2evo tables - echo get_install_format_text( "Calling modules for individual upgrades...
    \n", 'br' ); + echo get_install_format_text_and_log( "Calling modules for individual upgrades...
    \n", 'br' ); evo_flush(); modules_call_method( 'upgrade_b2evo_tables' ); @@ -12699,7 +13082,7 @@ function upg_convert_plugin_coll_checkbox_settings( $plugin_classname, $setting_ $Plugins = new Plugins(); } - echo get_install_format_text( '

    '.T_('Clearing caches...').'

    ', 'h2' ); + echo get_install_format_text_and_log( '

    '.T_('Clearing caches...').'

    ', 'h2' ); evo_flush(); // Init Caches: @@ -12716,10 +13099,10 @@ function upg_convert_plugin_coll_checkbox_settings( $plugin_classname, $setting_ { // Display errors of the cache checking foreach( $check_cache_messages as $check_cache_message ) { - echo get_install_format_text( '
    ', 'br' ); - echo get_install_format_text( ''.$check_cache_message.'' ); + echo get_install_format_text_and_log( '
    ', 'br' ); + echo get_install_format_text_and_log( ''.$check_cache_message.'' ); } - echo get_install_format_text( '
    ', 'br' ); + echo get_install_format_text_and_log( '
    ', 'br' ); } task_end(); @@ -12740,7 +13123,7 @@ function upg_convert_plugin_coll_checkbox_settings( $plugin_classname, $setting_ invalidate_pagecaches(); task_end(); - echo get_install_format_text( '

    '.T_('Letting plugins upgrade themselves...').'

    ', 'h2' ); + echo get_install_format_text_and_log( '

    '.T_('Letting plugins upgrade themselves...').'

    ', 'h2' ); evo_flush(); // Reload plugins after every upgrade, to detect even those changes on plugins which didn't require db modifications @@ -12758,11 +13141,11 @@ function upg_convert_plugin_coll_checkbox_settings( $plugin_classname, $setting_ install_basic_plugins( $old_db_version ); task_end(); - echo get_install_format_text( '

    '.T_('Checking defaults...').'

    ', 'h2' ); + echo get_install_format_text_and_log( '

    '.T_('Checking defaults...').'

    ', 'h2' ); evo_flush(); // Create default cron jobs (this can be done at each upgrade): - echo get_install_format_text( "Checking if some default cron jobs need to be installed...
    \n", 'br' ); + echo get_install_format_text_and_log( "Checking if some default cron jobs need to be installed...
    \n", 'br' ); evo_flush(); require_once dirname(__FILE__).'/_functions_create.php'; create_default_jobs( true ); @@ -12777,7 +13160,7 @@ function upg_convert_plugin_coll_checkbox_settings( $plugin_classname, $setting_ // URL to continue the upgrade process from install folder $recreate_excerpts = $recreate_autogenerated_excerpts ? '&recreate_excerpts=1' : ''; $upgrade_continue_url = $baseurl.'install/index.php?locale='.$locale.'&action='.$upgrade_action.'&exec_general_tasks=0'.$recreate_excerpts; - echo get_install_format_text( 'We are reaching the time limit for this script. Please click continue...' ); + echo get_install_format_text_and_log( 'We are reaching the time limit for this script. Please click continue...' ); // Dirty temporary solution: exit(0); } @@ -12821,10 +13204,10 @@ function upg_convert_plugin_coll_checkbox_settings( $plugin_classname, $setting_ * Check to make sure the DB schema is up to date: * ----------------------------------------------- */ - echo get_install_format_text( '

    '.T_('Double checking DB structure...').'

    ', 'h2' ); + echo get_install_format_text_and_log( '

    '.T_('Double checking DB structure...').'

    ', 'h2' ); evo_flush(); - echo get_install_format_text( "Starting to check DB...
    \n", 'br' ); + echo get_install_format_text_and_log( "Starting to check DB...
    \n", 'br' ); evo_flush(); $upgrade_db_deltas = array(); // This holds changes to make, if any (just all queries) @@ -12835,8 +13218,8 @@ function upg_convert_plugin_coll_checkbox_settings( $plugin_classname, $setting_ { // For each table in the schema, check diffs... if( $debug ) { - echo get_install_format_text( '
    ', 'br' ); - echo get_install_format_text( 'Checking table: '.$table.': ' ); + echo get_install_format_text_and_log( '
    ', 'br' ); + echo get_install_format_text_and_log( 'Checking table: '.$table.': ' ); } $updates = db_delta( $query_info[1], array('drop_column', 'drop_index'), false, true ); if( empty($updates) ) @@ -12861,12 +13244,12 @@ function upg_convert_plugin_coll_checkbox_settings( $plugin_classname, $setting_ if( $debug ) { - echo get_install_format_text( '
    ', 'br' ); + echo get_install_format_text_and_log( '
    ', 'br' ); } if( empty($upgrade_db_deltas) ) { // no upgrades needed: - echo get_install_format_text( '

    '.T_('The database schema is up to date.').'

    ', 'p' ); + echo get_install_format_text_and_log( '

    '.T_('The database schema is up to date.').'

    ', 'p' ); } else { // Upgrades are needed: @@ -12880,7 +13263,7 @@ function upg_convert_plugin_coll_checkbox_settings( $plugin_classname, $setting_ { // received confirmation from form if( $upgrade_db_deltas_confirm_md5 != md5( implode('', $upgrade_db_deltas) ) ) { // unlikely to happen - echo get_install_format_text( '

    ' + echo get_install_format_text_and_log( '

    ' .T_('The DB schema has been changed since confirmation.') .'

    ', 'p' ); } @@ -12916,17 +13299,17 @@ function upg_convert_plugin_coll_checkbox_settings( $plugin_classname, $setting_ } - echo get_install_format_text( '

    '.T_('The version number is correct, but we have detected changes in the database schema. This can happen if you\'ve been using development versions directly off GitHub...').'

    ', 'p' ); + echo get_install_format_text_and_log( '

    '.T_('The version number is correct, but we have detected changes in the database schema. This can happen if you\'ve been using development versions directly off GitHub...').'

    ', 'p' ); - echo get_install_format_text( '

    '.T_('The following database changes will be carried out. If you are not sure what this means, it will probably be alright.').'

    ', 'p' ); + echo get_install_format_text_and_log( '

    '.T_('The following database changes will be carried out. If you are not sure what this means, it will probably be alright.').'

    ', 'p' ); - echo get_install_format_text( '
      ' ); + echo get_install_format_text_and_log( '
        ' ); foreach( $upgrade_db_deltas as $l_delta ) { #echo '
      • '.nl2br($l_delta).'
      • '; - echo get_install_format_text( '
      • '.str_replace( "\t", '  ', $l_delta ).'
      • ', 'li' ); + echo get_install_format_text_and_log( '
      • '.str_replace( "\t", '  ', $l_delta ).'
      • ', 'li' ); } - echo get_install_format_text( '
      ' ); + echo get_install_format_text_and_log( '
    ' ); if( empty( $display ) || $display != 'cli' ) { // Don't print form on CLI mode: diff --git a/install/_functions_install.php b/install/_functions_install.php index 9ae1626f7f6..3c5fd3e27ee 100644 --- a/install/_functions_install.php +++ b/install/_functions_install.php @@ -182,11 +182,11 @@ function install_newdb() if( $old_db_version = get_db_version() ) { - echo get_install_format_text( '

    '.T_('OOPS! It seems b2evolution is already installed!').'

    ', 'p' ); + echo get_install_format_text_and_log( '

    '.T_('OOPS! It seems b2evolution is already installed!').'

    ', 'p' ); if( $old_db_version < $new_db_version ) { - echo get_install_format_text( '

    '.sprintf( T_('Would you like to upgrade your existing installation now?'), 'href="?action=evoupgrade"' ).'

    ', 'p' ); + echo get_install_format_text_and_log( '

    '.sprintf( T_('Would you like to upgrade your existing installation now?'), 'href="?action=evoupgrade"' ).'

    ', 'p' ); } return; @@ -200,7 +200,7 @@ function install_newdb() */ $local_installation = param( 'local_installation', 'integer', ( $create_sample_contents == 'full' ? intval( check_local_installation() ) : 0 ) ); - echo get_install_format_text( '

    '.T_('Creating b2evolution tables...').'

    ', 'h2' ); + echo get_install_format_text_and_log( '

    '.T_('Creating b2evolution tables...').'

    ', 'h2' ); evo_flush(); create_tables(); @@ -208,7 +208,7 @@ function install_newdb() update_install_progress_bar(); // Create default data - echo get_install_format_text( '

    '.T_('Creating minimum default data...').'

    ', 'h2' ); + echo get_install_format_text_and_log( '

    '.T_('Creating minimum default data...').'

    ', 'h2' ); evo_flush(); create_default_data(); @@ -217,7 +217,7 @@ function install_newdb() if( $create_demo_organization || $create_demo_users ) { - echo get_install_format_text( '

    '.T_('Creating demo organization and users...').'

    ', 'h2' ); + echo get_install_format_text_and_log( '

    '.T_('Creating demo organization and users...').'

    ', 'h2' ); evo_flush(); // Create demo organization if selected: @@ -292,7 +292,7 @@ function install_newdb() { global $Settings, $install_test_features; - echo get_install_format_text( '

    '.T_('Creating demo website...').'

    ', 'h2' ); + echo get_install_format_text_and_log( '

    '.T_('Creating demo website...').'

    ', 'h2' ); evo_flush(); // We're gonna need some environment in order to create the demo contents... @@ -317,7 +317,7 @@ function install_newdb() // Call the following function even if no demo content will be installed. // We still need to install the shared widgets - install_basic_widgets( $new_db_version ); + install_basic_widgets(); // Create demo emails data like lists, campaigns, automations: create_demo_emails(); @@ -327,22 +327,35 @@ function install_newdb() track_step( 'install-success' ); + // Display installation data and instructions $install_result_title = T_('Installation successful!'); - $install_result_body = get_install_format_text( + echo get_install_format_text_and_log( '

    '.$install_result_title.'

    ', 'h2' ); + + global $avoid_log_file; + + $install_result_body = get_install_format_text_and_log( '

    ' .sprintf( T_('Now you can log in with the following credentials:'), 'href="'.$admin_url.'"' ) .'

    ', 'p' ) - .get_install_format_text( + .get_install_format_text_and_log( '' - .'', 'br' ) - .get_install_format_text( + .'', 'br' ); + + // Log password( not readable ) without printing in browser: + get_install_format_text_and_log( + '' + .'
    '.T_( 'Login' ).':  '.( isset( $install_login ) ? $install_login : 'admin' ).'
    '.T_( 'Login' ).':  '.( isset( $install_login ) ? $install_login : 'admin' ).'
    '.T_( 'Password' ).':  '.'**Not saved to the log file**'.'
    ', 'br' ); + + // Print password without log: + $avoid_log_file = true; + $install_result_body .= get_install_format_text_and_log( ''.T_( 'Password' ).':  '.$random_password.'' - .'', 'br' ) - .get_install_format_text( + .'', 'br' ); + $avoid_log_file = false; + + $install_result_body .= get_install_format_text_and_log( '

    '.T_('Note that password carefully! It is a random password that is given to you when you install b2evolution. If you lose it, you will have to delete the database tables and re-install anew.').'

    ', 'p' ); - // Display installation data and instructions - echo get_install_format_text( '

    '.$install_result_title.'

    ', 'h2' ); echo $install_result_body; // Modal window with installation data and instructions @@ -834,6 +847,9 @@ function install_basic_plugins( $old_db_version = 0 ) { install_plugin( 'content_blocks_plugin' ); } + + // Install additional plugins by modules: + modules_call_method( 'install_basic_plugins', array( 'old_db_version' => $old_db_version ) ); } @@ -862,7 +878,7 @@ function install_plugin( $plugin, $activate = true, $settings = array(), $params $edit_Plugin = & $Plugins_admin->install( $plugin, 'broken' ); // "broken" by default, gets adjusted later if( ! ( $edit_Plugin instanceof Plugin ) ) { // Broken plugin - echo get_install_format_text( ''.$edit_Plugin.'
    '."\n", 'br' ); + echo get_install_format_text_and_log( ''.$edit_Plugin.'
    '."\n", 'br' ); return false; } @@ -883,7 +899,7 @@ function install_plugin( $plugin, $activate = true, $settings = array(), $params $enable_return = $edit_Plugin->BeforeEnable(); if( $enable_return !== true ) { // Warning on enable a plugin - echo get_install_format_text( ''.$enable_return.'
    '."\n", 'br' ); + echo get_install_format_text_and_log( ''.$enable_return.'
    '."\n", 'br' ); // Set plugin status to "needs_config" to mark the plugin as incomplete for using: $Plugins_admin->set_Plugin_status( $edit_Plugin, 'needs_config' ); @@ -908,11 +924,11 @@ function install_plugin( $plugin, $activate = true, $settings = array(), $params /** - * Install basic widgets. + * Installing default widgets for all collections */ -function install_basic_widgets( $old_db_version = 0 ) +function install_basic_widgets() { - global $DB, $installed_default_shared_widgets; + global $installed_default_shared_widgets, $install_test_features, $blog_home_ID, $blog_a_ID, $blog_b_ID, $blog_photoblog_ID, $blog_forums_ID, $blog_manual_ID, $events_blog_ID, $demo_poll_ID; load_funcs( 'widgets/_widgets.funcs.php' ); @@ -924,26 +940,30 @@ function install_basic_widgets( $old_db_version = 0 ) task_end(); } - $blog_type = ( $old_db_version < 11010 ) ? '"std"' : 'blog_type'; - $SQL = new SQL( 'Get all collections with their skins before install basic widgets' ); - $SQL->SELECT( 'blog_ID, '.$blog_type.', blog_normal_skin_ID, blog_mobile_skin_ID, blog_tablet_skin_ID, blog_alt_skin_ID' ); - $SQL->FROM( 'T_blogs' ); - $SQL->GROUP_BY( 'blog_ID, blog_type' ); - $blogs_data = $DB->get_results( $SQL ); + // Load all collections: + $BlogCache = & get_BlogCache(); + $BlogCache->load_all(); - foreach( $blogs_data as $blog_data ) + foreach( $BlogCache->cache as $Blog ) { - task_begin( 'Installing default widgets for collection #'.$blog_data->blog_ID.'... ' ); - insert_basic_widgets( $blog_data->blog_ID, 'normal', true, $blog_data->blog_type ); - insert_basic_widgets( $blog_data->blog_ID, 'mobile', true, $blog_data->blog_type ); - insert_basic_widgets( $blog_data->blog_ID, 'tablet', true, $blog_data->blog_type ); - insert_basic_widgets( $blog_data->blog_ID, 'alt', true, $blog_data->blog_type ); + task_begin( 'Installing default widgets for collection #'.$Blog->ID.'... ' ); + $Blog->setup_default_widgets( 'all', array( + 'coll_home_ID' => $blog_home_ID, + 'coll_blog_a_ID' => $blog_a_ID, + 'coll_photoblog_ID' => $blog_photoblog_ID, + 'poll_ID' => $demo_poll_ID, + 'init_as_home' => ( $blog_home_ID == $Blog->ID ), + 'init_as_blog_a' => ( $blog_a_ID == $Blog->ID ), + 'init_as_blog_b' => ( $blog_b_ID == $Blog->ID ), + 'init_as_forums' => ( $blog_forums_ID == $Blog->ID ), + 'init_as_events' => ( $events_blog_ID == $Blog->ID ), + 'install_test_features' => $install_test_features, + ) ); task_end(); } } - function advanced_properties() { /* @@ -1143,14 +1163,14 @@ function create_relations() */ function install_htaccess( $upgrade = false, $force_htaccess = false ) { - echo get_install_format_text( '

    '.T_('Preparing to install /.htaccess in the base folder...').' (Force='.($force_htaccess?'yes':'no').')
    ', 'p-start-br' ); + echo get_install_format_text_and_log( '

    '.T_('Preparing to install /.htaccess in the base folder...').' (Force='.($force_htaccess?'yes':'no').')
    ', 'p-start-br' ); if( ! $force_htaccess ) { // Check if we run apache... $server = isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : ''; if( ! empty( $server ) && preg_match( '~(Nginx|Lighttpd|Microsoft-IIS)~i', $server ) ) { // Skip installation if this is not an Apache server - echo get_install_format_text( '
    '.T_('.htaccess is not needed because your web server is not Apache. WARNING: you will need to configure your web server manually.').'

    ', 'p-end' ); + echo get_install_format_text_and_log( '
    '.T_('.htaccess is not needed because your web server is not Apache. WARNING: you will need to configure your web server manually.').'

    ', 'p-end' ); return true; } } @@ -1160,7 +1180,7 @@ function install_htaccess( $upgrade = false, $force_htaccess = false ) if( $error_message ) { - echo get_install_format_text( ''.T_('ERROR!').'
    '.$error_message.'
    ' ); + echo get_install_format_text_and_log( ''.T_('ERROR!').'
    '.$error_message.'
    ' ); // Do we want to ignore the error? $htignore = param( 'htignore', 'integer', 0 ); @@ -1170,11 +1190,11 @@ function install_htaccess( $upgrade = false, $force_htaccess = false ) } else { // Some errors are existing with .htaccess file, Display a link to ignore the errors and continue instalation - echo get_install_format_text( '', 'li' ); + echo get_install_format_text_and_log( '', 'li' ); return false; } } - echo get_install_format_text( '

    ', 'p-end' ); + echo get_install_format_text_and_log( '

    ', 'p-end' ); return true; } @@ -1208,7 +1228,7 @@ function do_install_htaccess( $upgrade = false, $force_htaccess = false ) $content_sample_htaccess = @file_get_contents( $basepath.'sample.htaccess' ); if( $content_sample_htaccess === false ) { - return get_install_format_text( '
    We cannot read the sample.htaccess file. Please check file permissions to make sure PHP can read this file.
    ' ); + return get_install_format_text_and_log( '
    We cannot read the sample.htaccess file. Please check file permissions to make sure PHP can read this file.
    ' ); } $content_sample_htaccess = trim( $content_sample_htaccess ); $content_htaccess = trim( @file_get_contents( $basepath.'.htaccess' ) ); @@ -1217,20 +1237,20 @@ function do_install_htaccess( $upgrade = false, $force_htaccess = false ) { // The .htaccess file has content that different from a sample file if( $upgrade ) { - echo get_install_format_text( ''.T_('.htaccess is already installed BUT DOES NOT match sample.htaccess. Please check the differences manually.').'' ); + echo get_install_format_text_and_log( ''.T_('.htaccess is already installed BUT DOES NOT match sample.htaccess. Please check the differences manually.').'' ); return ''; } else { - echo get_install_format_text( '

    '.T_('There is already a file called .htaccess at the blog root. If you don\'t specifically need this file, it is recommended that you delete it or rename it to old.htaccess before you continue. This will allow b2evolution to create a new .htaccess file that is optimized for best results.').'

    ', 'p' ); + echo get_install_format_text_and_log( '

    '.T_('There is already a file called .htaccess at the blog root. If you don\'t specifically need this file, it is recommended that you delete it or rename it to old.htaccess before you continue. This will allow b2evolution to create a new .htaccess file that is optimized for best results.').'

    ', 'p' ); echo T_('Here are the contents of the current .htaccess file:'); - echo get_install_format_text( '
    '.htmlspecialchars( $content_htaccess ).'

    ', 'code' ); - return get_install_format_text( sprintf( T_('Again, we recommend you remove this file before continuing. If you chose to keep it, b2evolution will probably still work, but for optimization you should follow these instructions.'), 'href="'.get_manual_url( 'htaccess-file' ).'" target="_blank"' ) ); + echo get_install_format_text_and_log( '
    '.htmlspecialchars( $content_htaccess ).'

    ', 'code' ); + return get_install_format_text_and_log( sprintf( T_('Again, we recommend you remove this file before continuing. If you chose to keep it, b2evolution will probably still work, but for optimization you should follow these instructions.'), 'href="'.get_manual_url( 'htaccess-file' ).'" target="_blank"' ) ); } } else { // Installed file is the same as recommended: - echo get_install_format_text( ''.T_('.htaccess is already installed and matches sample.htaccess.').'' ); + echo get_install_format_text_and_log( ''.T_('.htaccess is already installed and matches sample.htaccess.').'' ); return ''; } } @@ -1246,7 +1266,7 @@ function do_install_htaccess( $upgrade = false, $force_htaccess = false ) load_funcs('_core/_url.funcs.php'); $fetch_test_url = $baseurl.'install/test/'; $info = array(); - echo get_install_format_text( T_('Verifying .htaccess support works by fetching:').' '.$fetch_test_url.'... ' ); + echo get_install_format_text_and_log( T_('Verifying .htaccess support works by fetching:').' '.$fetch_test_url.'... ' ); if( ! $remote_page = fetch_remote_page( $fetch_test_url, $info ) ) { return $info['error']; @@ -1263,7 +1283,7 @@ function do_install_htaccess( $upgrade = false, $force_htaccess = false ) return T_('Test was successful, but failed to copy .htaccess into baseurl directory!'); } - echo get_install_format_text( ''.T_('.htaccess installation successful!').'' ); + echo get_install_format_text_and_log( ''.T_('.htaccess installation successful!').'' ); return ''; } @@ -1307,7 +1327,7 @@ function display_install_back_link() { global $default_locale; - echo get_install_format_text( '
    ', 'auto', '', true, - '', - [ 'Insert Poll' ], - true ); - - // Load available polls - polls_load_polls( prefix ); - - // To prevent link default event - return false; - } - - function polls_api_request( api_path, obj_selector, func ) - { - jQuery.ajax( { - url: restapi_url + api_path - } ) - .then( func, function( jqXHR ) - { - polls_api_print_error( obj_selector, jqXHR ); - } ); - } - - function polls_api_print_error( obj_selector, error ) - { - if( typeof( error ) != 'string' && typeof( error.code ) == 'undefined' ) - { - error = typeof( error.responseJSON ) == 'undefined' ? error.statusText : error.responseJSON; - } - - if( typeof( error.code ) == 'undefined' ) - { // Unknown non-JSON response - var error_text = '

    Unknown error: ' + error + '

    '; - } - else - { - var error_text = '

    ' + error.message + '

    '; - - error_text += '
    Code: ' + error.code + '
    ' - + '
    Status: ' + error.data.status + '
    '; - - } - - jQuery( obj_selector ).html( error_text ); - } - - function polls_load_polls( prefix ) + else { - prefix = ( prefix ? prefix : '' ); - - polls_api_request( 'polls', '#poll_wrapper', function( data ) - { - var r = '
    '; - - jQuery( '#poll_wrapper' ).html( r ); - - } ); + expose_var_to_js( 'polls_toolbar_'.$params['js_prefix'], $js_config, 'evo_init_polls_toolbar_config' ); } - // Insert a poll short tag to textarea - jQuery( document ).on( 'click', '#polls_list a[data-poll-id]', function() - { - if( typeof( tinyMCE ) != 'undefined' && typeof( tinyMCE.activeEditor ) != 'undefined' && tinyMCE.activeEditor ) - { - tinyMCE.execCommand( 'mceFocus', false, tinyMCE.activeEditor.id ); - } - - var prefix = jQuery( this ).data( 'prefix' ) ? jQuery( this ).data( 'prefix' ) : ''; - - // Insert tag text in area - textarea_wrap_selection( window[ prefix + 'b2evoCanvas' ], '[poll:' + jQuery( this ).data( 'pollId' ) + ']', '', 0 ); - // Close main modal window - closeModalWindow(); - - // To prevent link default event - return false; - } ); - - //]]> - - get_template( 'toolbar_before', array( '$toolbar_class$' => $params['js_prefix'].$this->code.'_toolbar' ) ); echo $this->get_template( 'toolbar_after' ); - ?> - - \ No newline at end of file +?> diff --git a/plugins/prism_plugin/_prism.plugin.php b/plugins/prism_plugin/_prism.plugin.php index 82a8ccbc1dd..0e8fee40d8d 100644 --- a/plugins/prism_plugin/_prism.plugin.php +++ b/plugins/prism_plugin/_prism.plugin.php @@ -21,7 +21,7 @@ class prism_plugin extends Plugin var $group = 'rendering'; var $short_desc; var $long_desc; - var $version = '7.1.7'; + var $version = '7.2.5'; var $number_of_installs = 1; @@ -35,6 +35,30 @@ function PluginInit( & $params ) } + /** + * Define here default custom settings that are to be made available in the backoffice. + * + * @param array Associative array of parameters. + * @return array See {@link Plugin::get_custom_setting_definitions()}. + */ + function get_custom_setting_definitions( & $params ) + { + return array( + 'force_load_assets' => array( + 'label' => T_('Force loading plugin JS/CSS on'), + 'type' => 'checklist', + 'options' => array( + array( 'single', 'disp=single, disp=page', 0 ), + array( 'posts', 'disp=posts', 0 ), + array( 'comments', 'disp=comments', 0 ), + array( 'front', 'disp=front', 0 ), + array( 'other_disps', T_('other disps'), 0 ), + ) + ), + ); + } + + /** * Filters out the custom tag that would not validate, PLUS escapes the actual code. * @@ -71,14 +95,14 @@ function CommentFormSent( & $params ) $ItemCache = & get_ItemCache(); $comment_Item = & $ItemCache->get_by_ID( $params['comment_item_ID'], false ); if( !$comment_Item ) - { // Incorrect item + { // Incorrect item return false; } $item_Blog = & $comment_Item->get_Blog(); $apply_rendering = $this->get_coll_setting( 'coll_apply_comment_rendering', $item_Blog ); if( $this->is_renderer_enabled( $apply_rendering, $params['renderers'] ) ) - { // render code blocks in comment + { // render code blocks in comment $params['content' ] = & $params['comment']; $this->FilterItemContents( $params ); } @@ -92,7 +116,7 @@ function MessageThreadFormSent( & $params ) { $apply_rendering = $this->get_msg_setting( 'msg_apply_rendering' ); if( $this->is_renderer_enabled( $apply_rendering, $params['renderers'] ) ) - { // render code blocks in message + { // render code blocks in message $this->FilterItemContents( $params ); } } @@ -196,7 +220,7 @@ function filter_code_callback( $block ) $content = isset( $block[3] ) ? trim( $block[3] ) : ''; if( empty( $content ) ) - { // Don't render if no code content + { // Don't render if no code content return ''; } @@ -206,7 +230,7 @@ function filter_code_callback( $block ) // Language: $lang = strtolower( preg_replace( '/.*lang="?([a-z]+)"?.*/i', '$1', html_entity_decode( $block[2] ) ) ); if( ! in_array( $lang, array( 'php', 'css', 'javascript', 'sql', 'html', 'markup', 'apacheconf' ) ) ) - { // Use Markup for unknown language + { // Use Markup for unknown language $lang = ''; } @@ -230,7 +254,7 @@ function filter_code_callback( $block ) $r = ''.$content.''; if( $type == 'codeblock' ) - { // Set special template and attributes only for codeblock + { // Set special template and attributes only for codeblock // Detect number of start line: $line = intval( preg_replace( '/.*line="?(-?[0-9]+)"?.*/i', '$1', html_entity_decode( $block[2] ) ) ); @@ -270,13 +294,13 @@ function unfilter_code_callback( $block ) $content = $block[6]; if( empty( $block[1] ) ) - { // [codespan] + { // [codespan] $code_tag = 'codespan'; // codespan doesn't provide line numbers $line = ''; } else - { // [codeblock] + { // [codeblock] $code_tag = 'codeblock'; // Detect number of start line: preg_match( '/.*data-start="(-?[0-9]+)".*/i', html_entity_decode( $block[1] ), $line ); @@ -315,42 +339,80 @@ function unfilter_code_callback( $block ) /** - * Event handler: Called at the beginning of the skin's HTML HEAD section. - * - * Use this to add any HTML HEAD lines (like CSS styles or links to resource files (CSS, JavaScript, ..)). - * - * @param array Associative array of parameters + * Check if plugin JS or CSS should be loaded based on the current $disp */ - function SkinBeginHtmlHead( & $params ) + function load_assets() { - global $Collection, $Blog; + global $Collection, $Blog, $disp, $evo_renderers_used_in_current_page; - if( ! isset( $Blog ) || ( - $this->get_coll_setting( 'coll_apply_rendering', $Blog ) == 'never' && - $this->get_coll_setting( 'coll_apply_comment_rendering', $Blog ) == 'never' ) ) - { // Don't load css/js files when plugin is not enabled - return; + if( is_array( $evo_renderers_used_in_current_page ) && + in_array( $this->code, $evo_renderers_used_in_current_page ) ) + { // Load load CSS/JS files if this plugin is used on the current page by any Item, Comment, etc.: + return true; } - $this->require_js( 'js/prism.min.js' ); - $this->require_css( 'css/prism.min.css' ); + // Force to load CSS/JS files even if this plugin is NOT used on the current page: + $force_load_assets = $this->get_coll_setting( 'force_load_assets', $Blog ); + switch( $disp ) + { + case 'single': + case 'page': + $asset_disp = 'single'; + break; + + case 'posts': + case 'comments': + case 'front': + $asset_disp = $disp; + break; + + default: + $asset_disp = 'other_disps'; + } + return ! empty( $force_load_assets[ $asset_disp ] ); } /** - * Event handler: Called when ending the admin html head section. + * Event handler: Called right after displaying the admin page footer. * * @param array Associative array of parameters * @return boolean did we do something? */ - function AdminEndHtmlHead( & $params ) + function AdminAfterPageFooter( & $params ) { global $ctrl; - if( $ctrl == 'campaigns' && get_param( 'tab' ) == 'send' && $this->get_email_setting( 'email_apply_rendering' ) ) + if( ( $ctrl == 'campaigns' ) && ( get_param( 'tab' ) == 'send' ) && $this->get_email_setting( 'email_apply_rendering' ) ) { // Load this only on form to preview email campaign: - $this->require_js( 'js/prism.min.js' ); - $this->require_css( 'css/prism.min.css' ); + $this->require_js_defer( 'js/prism.min.js', false, 'footerlines' ); + $this->require_css_async( 'css/prism.min.css', false, 'footerlines' ); + } + } + + + /** + * Event handler: Called at the end of the skin's HTML BODY section. + * + * Use this to add any HTML snippet at the end of the generated page. + * + * @param array Associative array of parameters + */ + function SkinEndHtmlBody( & $params ) + { + global $Collection, $Blog; + + if( ! isset( $Blog ) || ( + $this->get_coll_setting( 'coll_apply_rendering', $Blog ) == 'never' && + $this->get_coll_setting( 'coll_apply_comment_rendering', $Blog ) == 'never' ) ) + { // Don't load css/js files when plugin is not enabled + return; + } + + if( $this->load_assets() ) + { + $this->require_js_defer( 'js/prism.min.js', false, 'footerlines' ); + $this->require_css_async( 'css/prism.min.css', false, 'footerlines' ); } } @@ -364,7 +426,7 @@ function AdminEndHtmlHead( & $params ) function DisplayCommentToolbar( & $params ) { if( !empty( $params['Comment'] ) ) - { // Comment is set, get Blog from comment + { // Comment is set, get Blog from comment $Comment = & $params['Comment']; if( !empty( $Comment->item_ID ) ) { @@ -374,10 +436,10 @@ function DisplayCommentToolbar( & $params ) } if( empty( $Blog ) ) - { // Comment is not set, try global Blog + { // Comment is not set, try global Blog global $Collection, $Blog; if( empty( $Blog ) ) - { // We can't get a Blog, this way "apply_comment_rendering" plugin collection setting is not available + { // We can't get a Blog, this way "apply_comment_rendering" plugin collection setting is not available return false; } } @@ -436,16 +498,16 @@ function DisplayEmailToolbar( & $params ) function AdminDisplayToolbar( & $params ) { if( !empty( $params['Item'] ) ) - { // Item is set, get Blog from post + { // Item is set, get Blog from post $edited_Item = & $params['Item']; $Collection = $Blog = & $edited_Item->get_Blog(); } if( empty( $Blog ) ) - { // Item is not set, try global Blog + { // Item is not set, try global Blog global $Collection, $Blog; if( empty( $Blog ) ) - { // We can't get a Blog, this way "apply_rendering" plugin collection setting is not available + { // We can't get a Blog, this way "apply_rendering" plugin collection setting is not available return false; } } @@ -501,7 +563,7 @@ function display_toolbar( $params ) echo $this->get_template( 'toolbar_after' ); // Load js to work with textarea - require_js( 'functions.js', 'blog', true, true ); + require_js_defer( 'functions.js', 'blog', true ); ?> + - get_template( 'toolbar_before', array( '$toolbar_class$' => $params['js_prefix'].$this->code.'_toolbar' ) ); echo $this->get_template( 'toolbar_after' ); - ?> \ No newline at end of file +?> diff --git a/plugins/star_plugin/_star.plugin.php b/plugins/star_plugin/_star.plugin.php index 3cb629e0ad5..8aee3608173 100644 --- a/plugins/star_plugin/_star.plugin.php +++ b/plugins/star_plugin/_star.plugin.php @@ -23,7 +23,7 @@ class star_plugin extends Plugin var $code = 'b2evStar'; var $name = 'Star renderer'; var $priority = 55; - var $version = '7.1.7'; + var $version = '7.2.5'; var $group = 'rendering'; var $short_desc; var $long_desc; diff --git a/plugins/test_plugin/_test.plugin.php b/plugins/test_plugin/_test.plugin.php index 7223bc5c6c9..acf5b9bb5c9 100644 --- a/plugins/test_plugin/_test.plugin.php +++ b/plugins/test_plugin/_test.plugin.php @@ -34,7 +34,7 @@ class test_plugin extends Plugin var $name = 'Test'; var $code = 'evo_TEST'; var $priority = 50; - var $version = '7.1.7'; + var $version = '7.2.5'; var $author = 'The b2evo Group'; var $help_url = ''; // empty URL defaults to manual wiki @@ -1080,7 +1080,7 @@ function InitMainList( & $params ) */ function SkinBeginHtmlHead( & $params ) { - require_js( '#jquery#', 'blog' ); + require_js_defer( '#jquery#', 'blog' ); } diff --git a/plugins/tinymce_plugin/_tinymce.plugin.php b/plugins/tinymce_plugin/_tinymce.plugin.php index c0eab353c4d..1d28803affd 100644 --- a/plugins/tinymce_plugin/_tinymce.plugin.php +++ b/plugins/tinymce_plugin/_tinymce.plugin.php @@ -25,7 +25,7 @@ * It provides replacing edit components with the JavaScript rich text editor TinyMCE. * * @todo Make sure settings get transformed from 0.6 to 0.7 and obsolete ones get dropped from the DB! - * @todo dh> use require_js() and add_js_headline() for the JavaScript includes + * @todo dh> use require_js_async() and require_js_defer() and add_js_headline() for the JavaScript includes * @todo fp> see bbcode plugin for an example about how to convert [tag] to on the fly for editing purposes. May be used for [img:] tags in b2evo. May also be used for b2evo smilies display. ed.onBeforeSetContent ed.onPostProcess * @todo fp> lang.js files should be moved to the standard language packs. Maybe served by .php files outputting javascript. * @todo dh> This is a nice plugin to apply classes and IDs: http://www.bram.us/projects/tinymce-plugins/tinymce-classes-and-ids-plugin-bramus_cssextras/ @@ -36,7 +36,7 @@ class tinymce_plugin extends Plugin var $code = 'evo_TinyMCE'; var $name = 'TinyMCE'; var $priority = 10; - var $version = '7.1.7'; + var $version = '7.2.5'; var $group = 'editor'; var $number_of_installs = 1; @@ -189,7 +189,7 @@ function GetDefaultSettings( & $params ) 'label' => $this->T_('Custom TinyMCE init'), 'type' => 'textarea', 'defaultvalue' => // Provide some sample: - 'height : "240"', + 'height : 240', 'note' => sprintf( $this->T_('Custom parameters to tinymce.init(). See the TinyMCE manual.'), 'href="http://wiki.moxiecode.com/index.php/TinyMCE:Configuration"' ), ), ); @@ -342,7 +342,7 @@ function GetDependencies() */ function AdminDisplayEditorButton( & $params ) { - global $wysiwyg_toggle_switch_js_initialized; + global $disable_tinymce_for_frontoffice_comment_form; if( empty( $params['content_id'] ) ) { // Value of html attribute "id" of textarea where tinymce is applied @@ -398,9 +398,6 @@ function AdminDisplayEditorButton( & $params ) } } - $show_wysiwyg_warning = $this->UserSettings->get( 'show_wysiwyg_warning_'.$Blog->ID ); - $wysiwyg_checkbox_label = TS_("Don't show this again for this Collection"); - $state_params = array( 'type' => $params['target_type'], 'blog' => $Blog->ID, @@ -414,9 +411,6 @@ function AdminDisplayEditorButton( & $params ) $this->target_type = 'EmailCampaign'; $this->target_ID = $edited_EmailCampaign->ID; - $show_wysiwyg_warning = $this->UserSettings->get( 'show_wysiwyg_warning_emailcampaign' ); - $wysiwyg_checkbox_label = TS_("Don't show this again when composing email campaigns"); - $state_params = array( 'type' => $params['target_type'], 'email' => $edited_EmailCampaign->ID, @@ -424,14 +418,19 @@ function AdminDisplayEditorButton( & $params ) break; case 'Comment': + if( ! is_admin_page() && $disable_tinymce_for_frontoffice_comment_form ) + { // Disable TinyMCE until JS can be fixed to defer load: + return false; + } + // Initialize settings for item: global $Collection, $Blog; $edited_Comment = & $params['target_object']; $edited_Item = & $edited_Comment->get_Item(); $this->target_type = 'Comment'; - $this->target_ID = $edited_Comment->ID; - $this->temp_ID = $params['temp_ID']; + $this->target_ID = $edited_Comment->ID; + $this->temp_ID = $params['temp_ID']; if( ! empty( $Blog ) && ! $Blog->get_setting( 'allow_html_comment' ) ) { // Only when HTML is allowed in comment: @@ -460,9 +459,6 @@ function AdminDisplayEditorButton( & $params ) } } - $show_wysiwyg_warning = $this->UserSettings->get( 'show_wysiwyg_warning_'.$Blog->ID ); - $wysiwyg_checkbox_label = TS_("Don't show this again for this Collection"); - // Currently shares the same editor state as Item above: $state_params = array( 'type' => $params['target_type'], @@ -485,9 +481,6 @@ function AdminDisplayEditorButton( & $params ) return false; } - $show_wysiwyg_warning = $this->UserSettings->get( 'show_wysiwyg_warning_message' ); - $wysiwyg_checkbox_label = TS_("Don't show this again when composing private messages"); - $state_params = array( 'type' => $params['target_type'], 'message' => empty( $edited_Message ) ? NULL : $edited_Message->ID, @@ -499,279 +492,72 @@ function AdminDisplayEditorButton( & $params ) return false; } + // JS config: + $tinymce_config = array( + 'content_id' => $params['content_id'], + 'plugin_code' => $this->code, + ); + switch( $params['edit_layout'] ) { default: // Get init params, depending on edit mode: simple|expert $tmce_init = $this->get_tmce_init( $params['edit_layout'], $params['content_id'], $params['target_type'] ); + + $toggle_editor_config = array( + 'save_state_html_url' => $this->get_htsrv_url( 'save_editor_state', array_merge( $state_params, array( 'on' => 0 ) ), '&' ), + 'save_state_wysiwyg_url' => $this->get_htsrv_url( 'save_editor_state', array_merge( $state_params, array( 'on' => 1 ) ), '&' ), + ); + $tinymce_config['toggle_editor'] = $toggle_editor_config; ?> -
    +
    - - - require_js( 'js/evo_view_shortcodes.bmin.js', true ); - ?> - - - require_js_defer( 'js/evo_init_plugin_tinymce.js', true ); + $this->require_js_defer( 'js/evo_view_shortcodes.bmin.js', true ); + $use_tinymce = $this->get_editor_state( $state_params ); - $editor_code = 'html'; + $tinymce_init_config = array( + 'use_tinymce' => $use_tinymce, + 'tmce_init' => $tmce_init, + 'display_error_msg' => sprintf( $this->T_('TinyMCE javascript could not be loaded. Check the "%s" plugin setting.'), $this->T_('URL to TinyMCE') ), + 'update_content_url' => $this->get_htsrv_url( 'convert_content_to_wysiwyg', array(), '&' ), + 'crumb_tinymce' => get_crumb( 'tinymce' ), + ); + $tinymce_config['editor'] = $tinymce_init_config; + if( $use_tinymce ) - { // User used MCE last time, load MCE on document.ready: + { // User used MCE last time, load MCE on document.ready: $editor_code = $this->code; - echo ''; } + // By default set the editor code to an empty string echo ''; - // If the js is enabled set the editor code to the currently used value - echo ''; + + if( is_ajax_request() ) + { + ?> + + htsrv_save_editor_state( array_merge( $state_params, array( 'on' => $use_tinymce ) ) ); @@ -825,7 +611,7 @@ function get_tmce_init( $edit_layout, $content_id, $target_type ) global $baseurl; // Get URL of TinyMCE JS files: - $tiny_mce_js_files_url = ( is_admin_page() || empty( $Blog ) ? $rsc_url : $Blog->get_local_rsc_url() ).'js/tiny_mce/'; + $tiny_mce_js_files_url = ( is_admin_page() || empty( $Blog ) ? $rsc_url : $Blog->get_local_rsc_url() ).'ext/tiny_mce/'; $tmce_plugins_array = array( 'image', @@ -951,7 +737,7 @@ function get_tmce_init( $edit_layout, $content_id, $target_type ) $tmce_language = substr($current_locale, 0, 2); // waltercruz> Fallback to english if there's no tinymce equivalent to the user locale // to avoid some strange screens like http://www.flickr.com/photos/waltercruz/3390729964/ - $lang_path = $rsc_path.'js/tiny_mce/langs/'.$tmce_language.'.js'; + $lang_path = $rsc_path.'ext/tiny_mce/langs/'.$tmce_language.'.js'; if( !file_exists( $lang_path ) ) { $tmce_language = 'en'; @@ -959,27 +745,33 @@ function get_tmce_init( $edit_layout, $content_id, $target_type ) // Configuration: -- http://wiki.moxiecode.com/index.php/TinyMCE:Configuration $init_options = array(); - $init_options[] = 'blog_ID: '.( !empty($Blog) ? $Blog->ID : 'null' ); - $init_options[] = 'cache_suffix: "?v='.$this->version.'"'; - $init_options[] = 'selector: "textarea#'.$content_id.'"'; + + $init_options['blog_ID'] = !empty( $Blog ) ? $Blog->ID : NULL; + $init_options['cache_suffix'] = '?v='.$this->version; + $init_options['selector'] = 'textarea#'.$content_id; + if( $this->Settings->get( 'use_gzip_compressor' ) ) { // Load script to use gzip compressor: - $init_options[] = 'script_url: "'.get_require_url( 'tiny_mce/tinymce.gzip.php', 'blog', 'js' ).'"'; + $init_options['script_url'] = get_require_url( 'ext:tiny_mce/tinymce.gzip.php', 'blog', 'js' ); } // B2evo plugin options - $init_options[] = 'collection: "'.$this->collection.'"'; - $init_options[] = 'target_ID: '.( empty( $this->target_ID ) ? 'undefined' : $this->target_ID ); - $init_options[] = 'temp_ID: '.( empty( $this->temp_ID ) ? 'undefined' : $this->temp_ID ); - $init_options[] = 'target_type: "'.( empty( $this->target_type ) ? 'undefined' : format_to_js( $this->target_type ) ).'"'; - - $init_options[] = 'rest_url: "'.get_htsrv_url().'rest.php"'; - $init_options[] = 'anon_async_url: "'.get_htsrv_url().'anon_async.php"'; + $init_options['collection'] = $this->collection; $insert_inline_modal_params = array( - 'target_type' => $this->target_type, - 'target_ID' => $this->target_ID, - 'request_from' => is_admin_page() ? 'back' : 'front', - ); + 'request_from' => is_admin_page() ? 'back' : 'front', + ); + + $init_options['target_ID'] = isset( $this->target_ID ) ? $this->target_ID : NULL; + $insert_inline_modal_params['target_ID'] = isset( $this->target_ID ) ? $this->target_ID : NULL; + + $init_options['temp_ID'] = isset( $this->temp_ID ) ? $this->temp_ID : NULL; + + $init_options['target_type'] = isset( $this->target_type ) ? $this->target_type : NULL; + $insert_inline_modal_params['target_type'] = isset( $this->target_type ) ? $this->target_type : NULL; + + $init_options['rest_url'] = get_htsrv_url().'rest.php'; + $init_options['anon_async_url'] = get_htsrv_url().'anon_async.php'; + if( $Blog ) { $insert_inline_modal_params['blog'] = $Blog->ID; @@ -988,49 +780,51 @@ function get_tmce_init( $edit_layout, $content_id, $target_type ) { $insert_inline_modal_params['temp_ID'] = $this->temp_ID; } - $init_options[] = 'modal_url: "'.$this->get_htsrv_url( 'insert_inline', $insert_inline_modal_params, '&' ).'"'; - $init_options[] = 'fontsize_formats: "8pt 10pt 12pt 14pt 16pt 18pt 24pt 36pt"'; + $init_options['modal_url'] = $this->get_htsrv_url( 'insert_inline', $insert_inline_modal_params, '&' ); + + $init_options['fontsize_formats'] = '8pt 10pt 12pt 14pt 16pt 18pt 24pt 36pt'; - // TinyMCE Theme+Skin+Variant to use: - $init_options[] = 'theme : "modern"'; - $init_options[] = 'menubar : false'; + $init_options['theme'] = 'modern'; + $init_options['menubar'] = false; + + $init_options['plugins'] = $tmce_plugins; + $init_options['external_plugins'] = array( + 'morebreak' => $tiny_mce_js_files_url.'plugins/morebreak/plugin.min.js' + ); + $init_options['morebreak_separator'] = '[teaserbreak]'; + $init_options['pagebreak_separator'] = '[pagebreak]'; - // comma separated list of plugins: -- http://wiki.moxiecode.com/index.php/TinyMCE:Plugins - $init_options[] = 'plugins : "'.$tmce_plugins.'"'; - $init_options[] = 'external_plugins: { - "morebreak" : "'.$tiny_mce_js_files_url.'plugins/morebreak/plugin.min.js" - }'; - $init_options[] = 'morebreak_separator : "[teaserbreak]"'; - $init_options[] = 'pagebreak_separator : "[pagebreak]"'; // Toolbars: - $init_options[] = 'toolbar1: "'.$tmce_theme_advanced_buttons1.'"'; - $init_options[] = 'toolbar2: "'.$tmce_theme_advanced_buttons2.'"'; - $init_options[] = 'toolbar3: "'.$tmce_theme_advanced_buttons3.'"'; - $init_options[] = 'toolbar4: "'.$tmce_theme_advanced_buttons4.'"'; + $init_options['toolbar1'] = $tmce_theme_advanced_buttons1; + $init_options['toolbar2'] = $tmce_theme_advanced_buttons2; + $init_options['toolbar3'] = $tmce_theme_advanced_buttons3; + $init_options['toolbar4'] = $tmce_theme_advanced_buttons4; + // Context menu: if( $this->Settings->get( 'tmce_options_contextmenu' ) == 1 ) { - $init_options[] = 'contextmenu: "cut copy paste | link image | inserttable"'; + $init_options['contextmenu'] = 'cut copy paste | link image | inserttable'; } if( $this->Settings->get( 'tmce_options_spellcheck' ) == 1 ) { - $init_options[] = 'browser_spellcheck: true'; + $init_options['browser_spellcheck'] = true; } else { - $init_options[] = 'browser_spellcheck: false'; + $init_options['browser_spellcheck'] = false; } // UI options: - $init_options[] = 'block_formats : "Paragraph=p;Preformatted=pre;Block Quote=blockquote;Heading 2=h2;Heading 3=h3;Heading 4=h4;Heading 5=h5;Heading 6=h6;Address=address;Definition Term=dt;Definition Description=dd;DIV=div"'; - $init_options[] = 'resize : true'; - $init_options[] = 'language : "'.$tmce_language.'"'; - $init_options[] = 'language_url : "'.$tiny_mce_js_files_url.'langs/'.$tmce_language.'.js"'; + $init_options['block_formats'] = 'Paragraph=p;Preformatted=pre;Block Quote=blockquote;Heading 2=h2;Heading 3=h3;Heading 4=h4;Heading 5=h5;Heading 6=h6;Address=address;Definition Term=dt;Definition Description=dd;DIV=div'; + $init_options['resize'] = true; + $init_options['language'] = $tmce_language; + $init_options['language_url'] = $tiny_mce_js_files_url.'langs/'.$tmce_language.'.js'; + if( function_exists( 'enchant_broker_init' ) ) { // Requires Enchant spelling library - $init_options[] = 'spellchecker_rpc_url: \'spellchecker.php\''; + $init_options['spellchecker_rpc_url'] = 'spellchecker.php'; } // body_class : "my_class" // CSS used in the iframe/editable area: -- http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/content_css @@ -1038,13 +832,13 @@ function get_tmce_init( $edit_layout, $content_id, $target_type ) // TODO: we don't want all of basic.css here // Prevent object resizing in editor - $init_options[] = 'object_resizing : false'; + $init_options['object_resizing'] = false; - $init_options[] = 'extended_valid_elements : "figure[class],figcaption[class]"'; + $init_options['extended_valid_elements'] = 'figure[class],figcaption[class]'; // Options below should prevent insertion of

    for every newline: - //$init_options[] = 'force_p_newlines : false'; - //$init_options[] = 'forced_root_block : ""'; + //$init_options['force_p_newlines'] = false'; + //$init_options['forced_root_block'] = ''; // Content CSS: $content_css = array(); @@ -1076,49 +870,54 @@ function get_tmce_init( $edit_layout, $content_id, $target_type ) // Load the content css files from 3rd party code, e.g. other plugins: global $tinymce_content_css, $app_version_long; - $tinymce_content_css[] = get_require_url( $this->get_plugin_url().'evo_view.css', true, 'css', $this->version.'+'.$app_version_long ); - $tinymce_content_css[] = get_require_url( $this->get_plugin_url().'editor.css', true, 'css', $this->version.'+'.$app_version_long ); + $tinymce_content_css[] = get_require_url( $this->get_plugin_url().'evo_view.css', 'absolute', 'css', $this->version.'+'.$app_version_long ); + $tinymce_content_css[] = get_require_url( $this->get_plugin_url().'editor.css', 'absolute', 'css', $this->version.'+'.$app_version_long ); if( is_array( $tinymce_content_css ) && count( $tinymce_content_css ) ) { $content_css = implode( ',', array_merge( $content_css, $tinymce_content_css ) ); } - $init_options[] = 'content_css : "'.$content_css.'"'; + $init_options['content_css'] = $content_css; // Generated HTML code options: // Do not make the path relative to "document_base_url": - $init_options[] = 'relative_urls : false'; + //$init_options[] = 'relative_urls : false'; + $init_options['relative_urls'] = false; + // Do not convert absolute urls to relative if url domain is the same as current page, // (we should keep urls as they were entered manually, because urls can be broken if collection has different domain than back-office; also an issue with RSS feeds): - $init_options[] = 'convert_urls : false'; - $init_options[] = 'entity_encoding : "raw"'; + $init_options['convert_urls'] = false; + $init_options['entity_encoding'] = 'raw'; // Autocomplete options: - $init_options[] = 'autocomplete_options: autocomplete_static_options'; // Must be initialize before as string with usernames that are separated by comma - $init_options[] = 'autocomplete_options_url: restapi_url + "users/autocomplete"'; + $init_options['autocomplete_options'] = 'window.tinymce_autocomplete_static_options'; // Must be initialize before as string with usernames that are separated by comma + $init_options['autocomplete_options_url'] = get_restapi_url().'users/autocomplete'; // remove_linebreaks : false, // not documented: auto_cleanup_word : true, // Prevent auto generated

    that wrap around the views - //$init_options[] = 'forced_root_block: ""'; + //$init_options['forced_root_block'] = ''; // Enable advanced tab for images: - $init_options[] = 'image_advtab : true'; + $init_options['image_advtab'] = true; // Disable branding: - $init_options[] = 'branding : false'; - - - $init = implode( ",\n", $init_options ); + $init_options['branding'] = false; // custom conf: if( $tmce_custom_conf = $this->Settings->get('tmce_custom_conf') ) { - $init .= ",\n// tmce_custom_conf (from PluginSettings):\n".$tmce_custom_conf; + $tmce_custom_conf = preg_split("/\r\n|\n|\r/", $tmce_custom_conf); + foreach( $tmce_custom_conf as $row ) + { + list( $key, $value ) = explode( ':', $row ); + $init_options[trim( $key ) ] = trim( $value ); + } } - return $init; + + return $init_options; } @@ -1208,38 +1007,6 @@ function htsrv_insert_inline( $params ) } - /** - * AJAX callback to save WYSIWYG switch warning state (on or off). - * - * @param array Params - */ - function htsrv_save_wysiwyg_warning_state( $params ) - { - if( ! isset( $params['on'] ) ) - { // Wrong request: - return; - } - - switch( $params['type'] ) - { - case 'Item': - case 'Comment': - $this->UserSettings->set( 'show_wysiwyg_warning_'.intval( $params['blog'] ), intval( $params['on'] ) ); - break; - - case 'EmailCampaign': - $this->UserSettings->set( 'show_wysiwyg_warning_emailcampaign', intval( $params['on'] ) ); - break; - - case 'Message': - $this->UserSettings->set( 'show_wysiwyg_warning_message', intval( $params['on'] ) ); - break; - } - - $this->UserSettings->dbupdate(); - } - - /** * Get editor state * @@ -1369,7 +1136,7 @@ function htsrv_convert_content_to_wysiwyg( $params ) */ function GetHtsrvMethods() { - return array( 'save_editor_state', 'save_wysiwyg_warning_state', 'insert_inline'/*, 'get_item_content_css'*/, 'convert_content_to_wysiwyg' ); + return array( 'save_editor_state', 'insert_inline'/*, 'get_item_content_css'*/, 'convert_content_to_wysiwyg' ); } diff --git a/plugins/tinymce_plugin/editor.css b/plugins/tinymce_plugin/editor.css index a0d82aa00b8..9fae5e6882b 100644 --- a/plugins/tinymce_plugin/editor.css +++ b/plugins/tinymce_plugin/editor.css @@ -46,8 +46,8 @@ pre { height: 10px; border-top: 1px dotted #666; margin-top: 15px; - background: url("../../rsc/js/tiny_mce/skins/lightgray/img/pagebreak.gif") no-repeat center; + background: url("../../rsc/ext/tiny_mce/skins/lightgray/img/pagebreak.gif") no-repeat center; } .mce-morebreak { - background-image: url("../../rsc/js/tiny_mce/skins/lightgray/img/morebreak.gif"); + background-image: url("../../rsc/ext/tiny_mce/skins/lightgray/img/morebreak.gif"); } \ No newline at end of file diff --git a/plugins/tinymce_plugin/js/evo_init_plugin_tinymce.js b/plugins/tinymce_plugin/js/evo_init_plugin_tinymce.js new file mode 100644 index 00000000000..5081d74071c --- /dev/null +++ b/plugins/tinymce_plugin/js/evo_init_plugin_tinymce.js @@ -0,0 +1,291 @@ +/** + * This file initialize plugin "Table Contents" + * + * This file is part of the evoCore framework - {@link http://evocore.net/} + * See also {@link https://github.com/b2evolution/b2evolution}. + * + * @license GNU GPL v2 - {@link http://b2evolution.net/about/gnu-gpl-license} + * + * @copyright (c)2003-2020 by Francois PLANQUE - {@link http://fplanque.com/} + * + * Depends on: jQuery, tinyMCE + */ +jQuery( document ).ready( function() +{ + window.evo_init_tinymce = function evo_init_tinymce( config ) + { + if( config.toggle_editor ) + { + /** + * Toggles the TinyMCE editor + */ + window.tinymce_plugin_toggleEditor = function tinymce_plugin_toggleEditor( content_id, force_enable ) + { + var textarea = jQuery( '#' + content_id ); + jQuery( '[data-content-id="' + content_id + '"] [id^="tinymce_plugin_toggle_button_"]' ).removeClass( 'active' ).attr( 'disabled', 'disabled' ); + + if( ! window['tinymce_plugin_init_done_' + content_id] ) + { + window['tinymce_plugin_init_done_' + content_id] = true; + + // Call this method on init again, with "null" id, so that mceAddControl gets called. + window.tinymce_plugin_init_tinymce( function() + { + window.tinymce_plugin_toggleEditor( content_id, true ); + } ); + + return; + } + + if( ! window.tinymce.get( content_id ) || force_enable ) + { // Turn on WYSIWYG editor + window.tinymce.execCommand( 'mceAddEditor', false, content_id ); + jQuery.get( config.toggle_editor.save_state_wysiwyg_url ); + jQuery( '#tinymce_plugin_toggle_button_wysiwyg' ).addClass( 'active' ); + jQuery( '#tinymce_plugin_toggle_button_html' ).removeAttr( 'disabled' ); + jQuery( '[name="editor_code"]').attr( 'value', config.plugin_code ); + // Hide the plugin toolbars that allow to insert html tags + jQuery( '.quicktags_toolbar, .evo_code_toolbar, .evo_prism_toolbar, .b2evMark_toolbar, .evo_mermaid_toolbar' ).hide(); + jQuery( '#block_renderer_evo_code, #block_renderer_evo_prism, #block_renderer_b2evMark, #block_renderer_evo_mermaid' ).addClass( 'disabled' ); + jQuery( 'input#renderer_evo_code, input#renderer_evo_prism, input#renderer_b2evMark, input#renderer_evo_mermaid' ).each( function() + { + if( jQuery( this ).is( ':checked' ) ) + { + jQuery( this ).addClass( 'checked' ); + } + jQuery( this ).attr( 'disabled', 'disabled' ).removeAttr( 'checked' ); + } ); + + if( content_id && textarea.prop( 'required' ) ) + { + textarea.attr( 'data-required', true ); + textarea.removeAttr( 'required' ); + } + } + else + { // Hide the editor, Display only source HTML + window.tinymce.execCommand( 'mceRemoveEditor', false, content_id ); + jQuery.get( config.toggle_editor.save_state_html_url ); + jQuery( '#tinymce_plugin_toggle_button_html' ).addClass( 'active' ); + jQuery( '#tinymce_plugin_toggle_button_wysiwyg' ).removeAttr( 'disabled' ); + jQuery( '[name="editor_code"]' ).attr( 'value', 'html' ); + // Show the plugin toolbars that allow to insert html tags + jQuery( '.quicktags_toolbar, .evo_code_toolbar, .evo_prism_toolbar, .b2evMark_toolbar, .evo_mermaid_toolbar' ).show(); + jQuery( '#block_renderer_evo_code, #block_renderer_evo_prism, #block_renderer_b2evMark, #block_renderer_evo_mermaid' ).removeClass( 'disabled' ); + jQuery( 'input#renderer_evo_code, input#renderer_evo_prism, input#renderer_b2evMark, input#renderer_evo_mermaid' ).each( function() + { + if( jQuery( this ).hasClass( 'checked' ) ) + { + jQuery( this ).attr( 'checked', 'checked' ).removeClass( 'checked' ); + } + jQuery( this ).removeAttr( 'disabled' ); + } ); + + if( content_id && textarea.attr( 'data-required' ) ) + { + textarea.removeAttr( 'data-required' ); + textarea.attr( 'required', true ); + } + } + }; + + jQuery( '[id^=tinymce_plugin_toggle_button_]').click( function() + { + var content_id = jQuery( this ).parent().data( 'contentId' ); + + if( ! content_id ) + { // Content ID not found: + return false; + } + + window.tinymce_plugin_toggleEditor( content_id ); + } ); + } + + if( config.editor ) + { + window.tinymce_plugin_displayed_error = window.tinymce_plugin_displayed_error || false; + window['tinymce_plugin_init_done_' + config.content_id] = window['tinymce_plugin_init_done_' + config.content_id] || false; + + // Init array with all usernames from the page for autocomplete plugin + window.tinymce_autocomplete_static_options = []; + jQuery( '.user.login' ).each( function() + { + var login = jQuery( this ).text(); + if( login != '' && window.tinymce_autocomplete_static_options.indexOf( login ) == -1 ) + { + if( login[0] == '@' ) + { + login = login.substr( 1 ); + } + window.tinymce_autocomplete_static_options.push( login ); + } + } ); + window.tinymce_autocomplete_static_options = window.tinymce_autocomplete_static_options.join(); + + window.tinymce_plugin_init_tinymce = function tinymce_plugin_init_tinymce( oninit ) + { + // Init tinymce: + if( typeof window.tinymce == "undefined" ) + { + if( ! window.tinymce_plugin_displayed_error ) + { + alert( config.editor.display_error_msg ); + window.tinymce_plugin_displayed_error = true; + } + } + else + { + // Define oninit function for TinyMCE + if( typeof config.editor.tmce_init.oninit != "undefined" ) + { // Already defined: + oninit = function() { + config.editor.tmce_init.oninit(); + oninit(); + } + } + + config.editor.tmce_init.oninit = function () + { + // Why? + oninit(); + + // Provide hooks for textarea manipulation (where other plugins should hook into): + var ed = window.tinymce.get( config.content_id ); + if( ed && typeof b2evo_Callbacks == "object" ) + { + // add a callback, that returns the selected (raw) html: + b2evo_Callbacks.register_callback( 'get_selected_text_for_' + config.content_id, function( value ) + { + var inst = window.tinymce.get( config.content_id ); + if( ! inst ) return null; + return inst.selection.getContent(); + }, true ); + + // add a callback, that wraps a selection: + b2evo_Callbacks.register_callback( 'wrap_selection_for_' + config.content_id, function( params ) + { + var inst = window.tinymce.get( config.content_id ); + if( ! inst ) return null; + var sel = inst.selection.getContent(); + + if( params.replace ) + { + var value = params.before + params.after; + } + else + { + var value = params.before + sel + params.after; + } + inst.selection.setContent( value ); + + return true; + }, true ); + + // add a callback, that replaces a string + b2evo_Callbacks.register_callback( 'str_replace_for_' + config.content_id, function( params ) + { + var inst = window.tinymce.get( config.content_id ); + if( ! inst ) return null; + + // Replace substring with new value + inst.setContent( inst.getContent().replace( params.search, params.replace ) ); + + return true; + }, true ); + + // add a callback, that lets us insert raw content: + // DEPRECATED, used in b2evo 1.10.x + b2evo_Callbacks.register_callback( 'insert_raw_into_' + config.content_id, function( value ) + { + window.tinymce.execInstanceCommand( config.content_id, "mceInsertRawHTML", false, value ); + return true; + }, true ); + } + + var textarea = jQuery( '#' + config.content_id ); + if( textarea.prop( 'required' ) ) + { + textarea.attr( 'data-required', true ); + textarea.removeAttr( 'required' ); + } + }; + + // Try to add custom shortcuts from page: + config.editor.tmce_init.init_instance_callback = function( ed ) + { + if( window.shortcut_keys ) + { + for( var i = 0; i < window.shortcut_keys.length; i++ ) + { + var key = window.shortcut_keys[i]; + ed.shortcuts.add( key, 'b2evo shortcut key: ' + key, function() + { + window.shortcut_handler( key ); + } ); + } + } + }; + + // This option allows you to specify a callback that will be executed before the TinyMCE editor instance is rendered + config.editor.tmce_init.setup = function( ed ) + { + // Fired when the editor is fully initialized. + ed.on( 'init', config.editor.tmce_init.oninit ); + }; + + window.tinymce.on( 'AddEditor', function( e ) + { // Switching to WYSIWYG mode: + var textarea = jQuery( '#' + config.content_id ); + if( ! textarea.val().match( /<(p\s?|br\s?\/?)[^>]*>/i ) ) + { // Try to apply "Auto P" plugin(if it is installed) in order to replace + // new lines with

    or
    html tags if content has no them yet: + jQuery.ajax( + { + type: 'POST', + url: config.editor.update_content_url, + data: + { + 'content': textarea.val(), + 'crumb_tinymce': config.editor.crumb_tinymce, + }, + success: function( result ) + { + e.editor.setContent( result ); + } + } ); + } + return false; + } ); + + // Initialize TinyMCE: + window.tinymce.init( config.editor.tmce_init ); + } + }; + + if( config.editor.use_tinymce == 1 ) + { + window.tinymce_plugin_toggleEditor( config.content_id ); + } + + // Set editor code to current plugin code if JS is enabled and tinymce is used currently: + jQuery( '[name="editor_code"]' ).attr( 'value', config.editor.use_tinymce == 1 ? config.plugin_code : 'html' ); + } + }; + + if( typeof( evo_tinymce_config ) != 'undefined' ) + { + // Initialize each TinyMCE instance: + var evo_temp_config = Object.values( evo_tinymce_config ); + for( var i = 0, n = evo_temp_config.length; i < n; i++ ) + { + ( function() { + var config = evo_temp_config[i]; + + // Init: + window.evo_init_tinymce( config ); + } )(); + } + delete evo_temp_config; + } +} ); diff --git a/plugins/tinymce_plugin/js/evo_view_shortcodes.bmin.js b/plugins/tinymce_plugin/js/evo_view_shortcodes.bmin.js index b890616464c..b18a920d1ac 100644 --- a/plugins/tinymce_plugin/js/evo_view_shortcodes.bmin.js +++ b/plugins/tinymce_plugin/js/evo_view_shortcodes.bmin.js @@ -1 +1 @@ -var evo=evo||{};evo.shortcode={types:{image:{regexp:/()?(\[(image):(\d+):?([^\[\]]*)\])(<\/span>)?/g},thumbnail:{regexp:/()?(\[(thumbnail):(\d+):?([^\[\]]*)\])(<\/span>)?/g},inline:{regexp:/()?(\[(inline):(\d+):?([^\[\]]*)\])(<\/span>)?/g},button:{regexp:/()?(\[(button):image#(\d+)([^\[\]]*)\][^\[]*\[\/button\])(<\/span>)?/g},cta:{regexp:/()?(\[(cta):?\d*:image#(\d+)([^\[\]]*)\][^\[]*\[\/cta\])(<\/span>)?/g},like:{regexp:/()?(\[(like):image#(\d+)([^\[\]]*)\][^\[]*\[\/like\])(<\/span>)?/g},dislike:{regexp:/()?(\[(dislike):image#(\d+)([^\[\]]*)\][^\[]*\[\/dislike\])(<\/span>)?/g},activate:{regexp:/()?(\[(activate):image#(\d+)([^\[\]]*)\][^\[]*\[\/activate\])(<\/span>)?/g},unsubscribe:{regexp:/()?(\[(unsubscribe):image#(\d+)([^\[\]]*)\][^\[]*\[\/unsubscribe\])(<\/span>)?/g}},next:function(e,t,n){var i,o=evo.shortcode.regexp(e);if(o.lastIndex=n||0,i=o.exec(t))return{index:i.index,content:i[0],shortcode:evo.shortcode.fromMatch(i)}},regexp:function(e){return evo.shortcode.types[e].regexp},fromMatch:function(e){return new evo.shortcode({type:e[3],link_ID:e[4],content:e[5]})}},evo.shortcode=$.extend(function(e){this.type=e.type,this.link_ID=e.link_ID,this.content=e.content},evo.shortcode),function(t,i,n,w){"use strict";var v={},d={};i.views={register:function(e,t){v[e]=i.View.extend(w.extend(t,{type:e}))},unregister:function(e){delete v[e]},get:function(e){return v[e]},unbind:function(){w.each(d,function(e,t){t.unbind()})},setMarkers:function(e){var s,t,d=[{content:e}],c=this;w.each(v,function(a,r){t=d.slice(),d=[],w.each(t,function(e,t){var n,i,o=t.content;if(t.processed)d.push(t);else{for(;o&&(n=r.prototype.match(o));)n.index&&d.push({content:o.substring(0,n.index)}),i=(s=c.createInstance(a,n.content,n.options)).loader?".":s.text,d.push({content:s.ignore?i:''+i+"",processed:!0}),o=o.slice(n.index+n.content.length);o&&d.push({content:o})}})});var n=[];return w.each(d,function(e,t){return n.push(t.content)}),e=n.join("")},createInstance:function(e,t,n,i){var o,a,r=this.get(e);return t=tinymce.DOM.decode(t),!i&&(a=this.getInstance(t))?a:(o=encodeURIComponent(t),n=w.extend(n||{},{text:t,encodedText:o,renderedHTML:null}),d[t]=new r(n))},getInstance:function(e){return"string"==typeof e?d[e]:d[t.decodeURIComponent(w(e).attr("data-evo-view-text"))]},getText:function(e){return decodeURIComponent(w(e).attr("data-evo-view-text")||"")},render:function(r){var s=this,n=[];w.each(d,function(e,t){t.renderedHTML||n.push("tags[]="+encodeURI(t.text))}),n.length?(n=n.join("&"),i.View.prototype.getEditors(function(a){tinymce.util.XHR.send({url:a.getParam("anon_async_url")+"?action=render_inlines&type="+a.getParam("target_type")+"&id="+(null==a.getParam("target_ID")?"":a.getParam("target_ID"))+(a.getParam("temp_ID")?"&temp_link_owner_ID="+a.getParam("temp_ID"):""),content_type:"application/x-www-form-urlencoded",data:n,success:function(e){if(e){var t=tinymce.util.JSON.parse(e);for(var n in t){var i=a.dom.create("div"),o=a.dom.createFragment(t[n]);if(i.appendChild(o),n!=i.innerHTML)s.getInstance(n).renderedHTML=i.innerHTML}}w.each(d,function(e,t){t.render(t.renderedHTML,r)})}})})):w.each(d,function(e,t){t.render(t.renderedHTML,r)})},update:function(e,t,n,i){var o=this.getInstance(n);o&&o.update(e,t,n,i)},edit:function(n,i){var o=this.getInstance(i);o&&o.edit&&o.edit(o.text,function(e,t){o.update(e,n,i,t)})},remove:function(e,t){var n=this.getInstance(t);n&&n.remove(e,t)}},i.View=function(e){w.extend(this,e),this.initialize()},i.View.extend=function(e){function t(e){i.View.call(this,e)}for(name in(t.prototype=Object.create(i.View.prototype)).constructor=t,e)t.prototype[name]=e[name];return t},w.extend(i.View.prototype,{content:null,loader:!0,initialize:function(){},getContent:function(e){return this.content},render:function(e,t){var i=this;null!=e&&(this.content=e),e=this.getContent(),(this.loader||e)&&(t&&this.unbind(),this.replaceMarkers(),e&&this.setContent(e,function(e,t,n){w(t).data("rendered",!0),i.bindNode.call(i,e,t,n)},!!t&&null))},bindNode:function(){},unbindNode:function(){},unbind:function(){var i=this;this.getNodes(function(e,t,n){i.unbindNode.call(i,e,t,n),w(t).trigger("evo-view-unbind")},!0)},getEditors:function(n){w.each(tinymce.editors,function(e,t){t.plugins.evo_view&&n.call(this,t)},this)},getNodes:function(t,n){var i=this;this.getEditors(function(e){w(e.getBody()).find('[data-evo-view-text="'+i.encodedText+'"]').filter(function(){var e;return null==n||(e=!0===w(this).data("rendered"),n?e:!e)}).each(function(){t.call(i,e,this,w(this).find(".evo-view-content").get(0))})})},getMarkers:function(n){var i=this.encodedText;this.getEditors(function(e){var t=this;w(e.getBody()).find('[data-evo-view-marker="'+i+'"]').each(function(){n.call(t,e,this)})})},markerText:'

    ',replaceMarkers:function(){var a=this;this.getMarkers(function(e,t){var n,i=t===e.selection.getNode();if(a.loader||w(t).text()===a.text){var o=a.markerText.replace(/%encodedText%/g,a.encodedText).replace(/%viewType%/g,a.type);n=e.$(o),e.$(t).replaceWith(n),i&&e.evo.setViewCursor(!1,n[0])}else e.dom.setAttrib(t,"data-evo-view-marker",null)})},removeMarkers:function(){this.getMarkers(function(e,t){e.dom.setAttrib(t,"data-evo-view-marker",null)})},setContent:function(i,o,e){"object"===w.type(i)&&-1!==i.body.indexOf("
    '),n.innerHTML="",n.appendChild("string"==typeof i?e.dom.createFragment(i):i),o&&o.call(this,e,t,n)},e)},setIframes:function(p,h,g,e){var f=t.MutationObserver||t.WebKitMutationObserver||t.MozMutationObserver,m=this;this.getNodes(function(s,d,c){var v=s.dom,l="",u=s.getBody().className||"",e=s.getDoc().getElementsByTagName("head")[0];tinymce.each(v.$('link[rel="stylesheet"]',e),function(e,t){t.href&&-1===t.href.indexOf("skins/lightgray/content.min.css")&&-1===t.href.indexOf("skins/wordpress/wp-content.css")&&(l+=v.getOuterHTML(t))}),m.iframeHeight&&v.add(c,"div",{style:{width:"100%",height:m.iframeHeight}}),setTimeout(function(){var t,n,e,i,o;function a(){var e;o||t.contentWindow&&(e=w(t),m.iframeHeight=w(n.body).height(),e.height()!==m.iframeHeight&&(e.height(m.iframeHeight),s.nodeChanged()))}if(c.innerHTML="",t=v.add(c,"iframe",{src:tinymce.Env.ie?'javascript:""':"",frameBorder:"0",allowTransparency:"true",scrolling:"no",class:"evo-view-sandbox",style:{width:"100%",display:"block"},height:m.iframeHeight}),v.add(c,"div",{class:"evo-view-overlay"}),(n=t.contentWindow.document).open(),n.write(''+p+l+''+h+""),n.close(),m.iframeHeight&&(o=!0,setTimeout(function(){o=!1,a()},3e3)),w(t.contentWindow).on("load",a),f)(e=new f(_.debounce(a,100))).observe(n.body,{attributes:!0,childList:!0,subtree:!0}),w(d).one("evo-view-unbind",function(){e.disconnect()});else for(i=1;i<6;i++)setTimeout(a,700*i);function r(){n.body.className=s.getBody().className}s.on("evo-body-class-change",r),w(d).one("evo-view-unbind",function(){s.off("evo-body-class-change",r)}),g&&g.call(m,s,d,c)},50)},e)},setLoader:function(){this.setContent('
    ')},setError:function(e,t){this.setContent('

    '+e+"

    ")},match:function(e){var t=n.next(this.type,e);if(t)return{index:t.index,content:t.content,options:{shortcode:t.shortcode}}},update:function(i,o,a,r){w.each(v,function(e,t){var n=t.prototype.match(i);if(n)return w(a).data("rendered",!1),o.dom.setAttrib(a,"data-evo-view-text",encodeURIComponent(i)),v.createInstance(type,i,n.options,r).render(),o.focus(),!1})},remove:function(e,t){this.unbindNode.call(this,e,t,w(t).find(".evo-view-content").get(0)),w(t).trigger("evo-view-unbind"),e.dom.remove(t),e.focus()}})}(window,window.evo,window.evo.shortcode,window.jQuery),function(e,t,n){var i,o;i={loader:!0},o=n.extend({},i,{initialize:function(){this.renderedHTML=null}}),t.register("image",o);var a=n.extend({},o,{markerText:' '});t.register("thumbnail",a),t.register("inline",a);var r=n.extend({},o,{markerText:'
    '});t.register("button",r),t.register("cta",r),t.register("like",r),t.register("dislike",r),t.register("activate",r),t.register("unsubscribe",r)}(window,window.evo.views,window.jQuery); \ No newline at end of file +var evo=window.evo||{};evo.shortcode={types:{image:{regexp:/()?(\[(image):(\d+):?([^\[\]]*)\])(<\/span>)?/g},thumbnail:{regexp:/()?(\[(thumbnail):(\d+):?([^\[\]]*)\])(<\/span>)?/g},inline:{regexp:/()?(\[(inline):(\d+):?([^\[\]]*)\])(<\/span>)?/g},button:{regexp:/()?(\[(button):image#(\d+)([^\[\]]*)\][^\[]*\[\/button\])(<\/span>)?/g},cta:{regexp:/()?(\[(cta):?\d*:image#(\d+)([^\[\]]*)\][^\[]*\[\/cta\])(<\/span>)?/g},like:{regexp:/()?(\[(like):image#(\d+)([^\[\]]*)\][^\[]*\[\/like\])(<\/span>)?/g},dislike:{regexp:/()?(\[(dislike):image#(\d+)([^\[\]]*)\][^\[]*\[\/dislike\])(<\/span>)?/g},activate:{regexp:/()?(\[(activate):image#(\d+)([^\[\]]*)\][^\[]*\[\/activate\])(<\/span>)?/g},unsubscribe:{regexp:/()?(\[(unsubscribe):image#(\d+)([^\[\]]*)\][^\[]*\[\/unsubscribe\])(<\/span>)?/g}},next:function(e,t,n){var i,o=evo.shortcode.regexp(e);if(o.lastIndex=n||0,i=o.exec(t))return{index:i.index,content:i[0],shortcode:evo.shortcode.fromMatch(i)}},regexp:function(e){return evo.shortcode.types[e].regexp},fromMatch:function(e){return new evo.shortcode({type:e[3],link_ID:e[4],content:e[5]})}},evo.shortcode=$.extend(function(e){this.type=e.type,this.link_ID=e.link_ID,this.content=e.content},evo.shortcode),function(t,i,n,w){"use strict";var v={},d={};i.views={register:function(e,t){v[e]=i.View.extend(w.extend(t,{type:e}))},unregister:function(e){delete v[e]},get:function(e){return v[e]},unbind:function(){w.each(d,function(e,t){t.unbind()})},setMarkers:function(e){var s,t,d=[{content:e}],c=this;w.each(v,function(a,r){t=d.slice(),d=[],w.each(t,function(e,t){var n,i,o=t.content;if(t.processed)d.push(t);else{for(;o&&(n=r.prototype.match(o));)n.index&&d.push({content:o.substring(0,n.index)}),i=(s=c.createInstance(a,n.content,n.options)).loader?".":s.text,d.push({content:s.ignore?i:''+i+"",processed:!0}),o=o.slice(n.index+n.content.length);o&&d.push({content:o})}})});var n=[];return w.each(d,function(e,t){return n.push(t.content)}),e=n.join("")},createInstance:function(e,t,n,i){var o,a,r=this.get(e);return t=tinymce.DOM.decode(t),!i&&(a=this.getInstance(t))?a:(o=encodeURIComponent(t),n=w.extend(n||{},{text:t,encodedText:o,renderedHTML:null}),d[t]=new r(n))},getInstance:function(e){return"string"==typeof e?d[e]:d[t.decodeURIComponent(w(e).attr("data-evo-view-text"))]},getText:function(e){return decodeURIComponent(w(e).attr("data-evo-view-text")||"")},render:function(r){var s=this,n=[];w.each(d,function(e,t){t.renderedHTML||n.push("tags[]="+encodeURI(t.text))}),n.length?(n=n.join("&"),i.View.prototype.getEditors(function(a){tinymce.util.XHR.send({url:a.getParam("anon_async_url")+"?action=render_inlines&type="+a.getParam("target_type")+"&id="+(null==a.getParam("target_ID")?"":a.getParam("target_ID"))+(a.getParam("temp_ID")?"&temp_link_owner_ID="+a.getParam("temp_ID"):""),content_type:"application/x-www-form-urlencoded",data:n,success:function(e){if(e){var t=tinymce.util.JSON.parse(e);for(var n in t){var i=a.dom.create("div"),o=a.dom.createFragment(t[n]);if(i.appendChild(o),n!=i.innerHTML)s.getInstance(n).renderedHTML=i.innerHTML}}w.each(d,function(e,t){t.render(t.renderedHTML,r)})}})})):w.each(d,function(e,t){t.render(t.renderedHTML,r)})},update:function(e,t,n,i){var o=this.getInstance(n);o&&o.update(e,t,n,i)},edit:function(n,i){var o=this.getInstance(i);o&&o.edit&&o.edit(o.text,function(e,t){o.update(e,n,i,t)})},remove:function(e,t){var n=this.getInstance(t);n&&n.remove(e,t)}},i.View=function(e){w.extend(this,e),this.initialize()},i.View.extend=function(e){function t(e){i.View.call(this,e)}for(name in(t.prototype=Object.create(i.View.prototype)).constructor=t,e)t.prototype[name]=e[name];return t},w.extend(i.View.prototype,{content:null,loader:!0,initialize:function(){},getContent:function(e){return this.content},render:function(e,t){var i=this;null!=e&&(this.content=e),e=this.getContent(),(this.loader||e)&&(t&&this.unbind(),this.replaceMarkers(),e&&this.setContent(e,function(e,t,n){w(t).data("rendered",!0),i.bindNode.call(i,e,t,n)},!!t&&null))},bindNode:function(){},unbindNode:function(){},unbind:function(){var i=this;this.getNodes(function(e,t,n){i.unbindNode.call(i,e,t,n),w(t).trigger("evo-view-unbind")},!0)},getEditors:function(n){w.each(tinymce.editors,function(e,t){t.plugins.evo_view&&n.call(this,t)},this)},getNodes:function(t,n){var i=this;this.getEditors(function(e){w(e.getBody()).find('[data-evo-view-text="'+i.encodedText+'"]').filter(function(){var e;return null==n||(e=!0===w(this).data("rendered"),n?e:!e)}).each(function(){t.call(i,e,this,w(this).find(".evo-view-content").get(0))})})},getMarkers:function(n){var i=this.encodedText;this.getEditors(function(e){var t=this;w(e.getBody()).find('[data-evo-view-marker="'+i+'"]').each(function(){n.call(t,e,this)})})},markerText:'
    ',replaceMarkers:function(){var a=this;this.getMarkers(function(e,t){var n,i=t===e.selection.getNode();if(a.loader||w(t).text()===a.text){var o=a.markerText.replace(/%encodedText%/g,a.encodedText).replace(/%viewType%/g,a.type);n=e.$(o),e.$(t).replaceWith(n),i&&e.evo.setViewCursor(!1,n[0])}else e.dom.setAttrib(t,"data-evo-view-marker",null)})},removeMarkers:function(){this.getMarkers(function(e,t){e.dom.setAttrib(t,"data-evo-view-marker",null)})},setContent:function(i,o,e){"object"===w.type(i)&&-1!==i.body.indexOf("
    '),n.innerHTML="",n.appendChild("string"==typeof i?e.dom.createFragment(i):i),o&&o.call(this,e,t,n)},e)},setIframes:function(p,h,g,e){var f=t.MutationObserver||t.WebKitMutationObserver||t.MozMutationObserver,m=this;this.getNodes(function(s,d,c){var v=s.dom,l="",u=s.getBody().className||"",e=s.getDoc().getElementsByTagName("head")[0];tinymce.each(v.$('link[rel="stylesheet"]',e),function(e,t){t.href&&-1===t.href.indexOf("skins/lightgray/content.min.css")&&-1===t.href.indexOf("skins/wordpress/wp-content.css")&&(l+=v.getOuterHTML(t))}),m.iframeHeight&&v.add(c,"div",{style:{width:"100%",height:m.iframeHeight}}),setTimeout(function(){var t,n,e,i,o;function a(){var e;o||t.contentWindow&&(e=w(t),m.iframeHeight=w(n.body).height(),e.height()!==m.iframeHeight&&(e.height(m.iframeHeight),s.nodeChanged()))}if(c.innerHTML="",t=v.add(c,"iframe",{src:tinymce.Env.ie?'javascript:""':"",frameBorder:"0",allowTransparency:"true",scrolling:"no",class:"evo-view-sandbox",style:{width:"100%",display:"block"},height:m.iframeHeight}),v.add(c,"div",{class:"evo-view-overlay"}),(n=t.contentWindow.document).open(),n.write(''+p+l+''+h+""),n.close(),m.iframeHeight&&(o=!0,setTimeout(function(){o=!1,a()},3e3)),w(t.contentWindow).on("load",a),f)(e=new f(_.debounce(a,100))).observe(n.body,{attributes:!0,childList:!0,subtree:!0}),w(d).one("evo-view-unbind",function(){e.disconnect()});else for(i=1;i<6;i++)setTimeout(a,700*i);function r(){n.body.className=s.getBody().className}s.on("evo-body-class-change",r),w(d).one("evo-view-unbind",function(){s.off("evo-body-class-change",r)}),g&&g.call(m,s,d,c)},50)},e)},setLoader:function(){this.setContent('
    ')},setError:function(e,t){this.setContent('

    '+e+"

    ")},match:function(e){var t=n.next(this.type,e);if(t)return{index:t.index,content:t.content,options:{shortcode:t.shortcode}}},update:function(i,o,a,r){w.each(v,function(e,t){var n=t.prototype.match(i);if(n)return w(a).data("rendered",!1),o.dom.setAttrib(a,"data-evo-view-text",encodeURIComponent(i)),v.createInstance(type,i,n.options,r).render(),o.focus(),!1})},remove:function(e,t){this.unbindNode.call(this,e,t,w(t).find(".evo-view-content").get(0)),w(t).trigger("evo-view-unbind"),e.dom.remove(t),e.focus()}})}(window,window.evo,window.evo.shortcode,window.jQuery),function(e,t,n){var i,o;i={loader:!0},o=n.extend({},i,{initialize:function(){this.renderedHTML=null}}),t.register("image",o);var a=n.extend({},o,{markerText:' '});t.register("thumbnail",a),t.register("inline",a);var r=n.extend({},o,{markerText:'
    '});t.register("button",r),t.register("cta",r),t.register("like",r),t.register("dislike",r),t.register("activate",r),t.register("unsubscribe",r)}(window,window.evo.views,window.jQuery); \ No newline at end of file diff --git a/plugins/tinymce_plugin/js/shortcodes.js b/plugins/tinymce_plugin/js/shortcodes.js index a9ed5ece13a..841a04abd13 100644 --- a/plugins/tinymce_plugin/js/shortcodes.js +++ b/plugins/tinymce_plugin/js/shortcodes.js @@ -1,4 +1,4 @@ -var evo = evo || {}; +var evo = window.evo || {}; evo.shortcode = { types: { @@ -67,4 +67,4 @@ evo.shortcode = $.extend( function( options ) { this.type = options.type; this.link_ID = options.link_ID; this.content = options.content; -}, evo.shortcode ); \ No newline at end of file +}, evo.shortcode ); diff --git a/plugins/twitter_plugin/_twitter.plugin.php b/plugins/twitter_plugin/_twitter.plugin.php index bac3a405072..23686a4d558 100644 --- a/plugins/twitter_plugin/_twitter.plugin.php +++ b/plugins/twitter_plugin/_twitter.plugin.php @@ -41,7 +41,7 @@ class twitter_plugin extends Plugin */ var $code = 'evo_twitter'; var $priority = 50; - var $version = '7.1.7'; + var $version = '7.2.5'; var $author = 'b2evolution Group'; /* @@ -518,7 +518,7 @@ function htsrv_unlink_account( $params ) { // User settings $redirect_to = url_add_param( $admin_url, 'ctrl=user&user_tab=advanced&user_ID='.$target_id ); - if( isset( $current_User ) && ( !$current_User->check_perm( 'users', 'edit' ) ) && ( $target_id != $current_User->ID ) ) + if( isset( $current_User ) && ( ! check_user_perm( 'users', 'edit' ) ) && ( $target_id != $current_User->ID ) ) { // user is only allowed to update him/herself $Messages->add( T_('You are only allowed to update your own profile!'), 'error' ); header_redirect( $redirect_to ); diff --git a/plugins/videoplug_plugin/_videoplug.plugin.php b/plugins/videoplug_plugin/_videoplug.plugin.php index 3d72256a0e3..c2db9b5cb65 100644 --- a/plugins/videoplug_plugin/_videoplug.plugin.php +++ b/plugins/videoplug_plugin/_videoplug.plugin.php @@ -25,7 +25,7 @@ class videoplug_plugin extends Plugin var $group = 'rendering'; var $short_desc; var $long_desc; - var $version = '7.1.7'; + var $version = '7.2.5'; var $number_of_installs = 1; @@ -128,8 +128,11 @@ function get_coll_setting_definitions( & $params ) */ function SkinBeginHtmlHead( & $params ) { - $this->require_css( 'videoplug.css' ); - $this->require_js( 'videoplug.js' ); + $this->require_css( 'css/videoplug.min.css' ); + // Initialize config for video plugin: + expose_var_to_js( 'evo_plugin_videoplug_config', array( + 'youtube_lazyload_selector' => '.evo_youtube[data-embed]', + ) ); } @@ -491,7 +494,7 @@ function DisplayCodeToolbar( $params = array() ) echo $this->get_template( 'toolbar_after' ); // Load js to work with textarea - require_js( 'functions.js', 'blog', true, true ); + require_js_defer( 'functions.js', 'blog', true ); ?>get_template( 'toolbar_before', array( '$toolbar_class$' => $params['js_prefix'].$this->code.'_toolbar' ) ); echo $this->get_template( 'toolbar_after' ); - ?>get_plugin_url().'tinymce_editor.css', true, 'css', $this->version.'+'.$app_version_long ); + $tinymce_content_css[] = get_require_url( $this->get_plugin_url().'tinymce_editor.css', 'absolute', 'css', $this->version.'+'.$app_version_long ); // Print toolbar on screen return $this->DisplayCodeToolbar( $params ); @@ -301,8 +268,8 @@ function SkinBeginHtmlHead( & $params ) return; } - require_js( '#jquery#', 'blog' ); - $this->require_js( 'jquery.scrollwide.min.js' ); + require_js_defer( '#jquery#', 'blog' ); + $this->require_js_defer( 'jquery.scrollwide.min.js' ); $this->require_css( 'jquery.scrollwide.css' ); } @@ -319,8 +286,8 @@ function AdminEndHtmlHead( & $params ) if( $ctrl == 'campaigns' && get_param( 'tab' ) == 'send' && $this->get_email_setting( 'email_apply_rendering' ) ) { // Load this only on form to preview email campaign: - require_js( '#jquery#', 'blog' ); - $this->require_js( 'jquery.scrollwide.min.js' ); + require_js_defer( '#jquery#', 'blog' ); + $this->require_js_defer( 'jquery.scrollwide.min.js' ); $this->require_css( 'jquery.scrollwide.css' ); } } @@ -337,4 +304,4 @@ function RenderItemAsHtml( & $params ) } } -?> \ No newline at end of file +?> diff --git a/plugins/wikitables_plugin/_wikitables.plugin.php b/plugins/wikitables_plugin/_wikitables.plugin.php index ede560a1106..29c0d62bfd7 100644 --- a/plugins/wikitables_plugin/_wikitables.plugin.php +++ b/plugins/wikitables_plugin/_wikitables.plugin.php @@ -22,7 +22,7 @@ class wikitables_plugin extends Plugin var $code = 'b2evWiTa'; var $name = 'Wiki Tables'; var $priority = 15; - var $version = '7.1.7'; + var $version = '7.2.5'; var $group = 'rendering'; var $short_desc; var $long_desc; @@ -331,11 +331,11 @@ function SkinBeginHtmlHead( & $params ) if( ! isset( $Blog ) || ( $this->get_coll_setting( 'coll_apply_rendering', $Blog ) == 'never' && $this->get_coll_setting( 'coll_apply_comment_rendering', $Blog ) == 'never' ) ) - { // Don't load css/js files when plugin is not enabled + { // Don't load css/js files when plugin is not enabled return; } - $this->require_css( 'wikitables.css' ); + $this->require_css_async( 'wikitables.css', false, 'footerlines' ); } @@ -374,4 +374,4 @@ function fix_tag_attributes( $attributes, $element ) } } -?> \ No newline at end of file +?> diff --git a/readme.html b/readme.html index a3fe8769ed8..11be4830b78 100644 --- a/readme.html +++ b/readme.html @@ -6,7 +6,7 @@ b2evolution readme - + @@ -34,7 +34,7 @@

    Welcome to b2evolution!

    b2evolution CMS

    b2evolution CMS

    -

    This is b2evolution CMS version 7.1.7-stable.

    +

    This is b2evolution CMS version 7.2.5-stable.

    A complete engine for your website !

    Multiblog/CMS + user community + email marketing + social network + more... b2evolution includes everything you need to run and maintain a modern website. diff --git a/readme.md b/readme.md index 0c4f8d45dc9..a8f46eca7b0 100644 --- a/readme.md +++ b/readme.md @@ -2,7 +2,7 @@ # b2evolution CMS -This is b2evolution CMS version **7.1.7-stable**. +This is b2evolution CMS version **7.2.5-stable**. ## A complete engine for your website ! diff --git a/readme.template.html b/readme.template.html index 3ddddbcc957..88db15ccc4c 100644 --- a/readme.template.html +++ b/readme.template.html @@ -6,7 +6,7 @@ b2evolution readme - + diff --git a/rest-api-demo/index.html b/rest-api-demo/index.html index 9e357a535b1..797a2454f99 100644 --- a/rest-api-demo/index.html +++ b/rest-api-demo/index.html @@ -4,12 +4,12 @@ REST API demo page - - + + - + '; + + if ($return) { + return $scriptTag; + } else { + echo $scriptTag; + } + } + + /** + * Returns a sanitized query string parameter. + * + * @param String $name Name of the query string param to get. + * @param String $default Default value if the query string item shouldn't exist. + * @return String Sanitized query string parameter value. + */ + public static function getParam($name, $default = "") { + if (!isset($_GET[$name])) { + return $default; + } + + return preg_replace("/[^0-9a-z\-_,]+/i", "", $_GET[$name]); // Sanatize for security, remove anything but 0-9,a-z,-_, + } + + /** + * Parses the specified time format into seconds. Supports formats like 10h, 10d, 10m. + * + * @param String $time Time format to convert into seconds. + * @return Int Number of seconds for the specified format. + */ + private function parseTime($time) { + $multipel = 1; + + // Hours + if (strpos($time, "h") > 0) { + $multipel = 3600; + } + + // Days + if (strpos($time, "d") > 0) { + $multipel = 86400; + } + + // Months + if (strpos($time, "m") > 0) { + $multipel = 2592000; + } + + // Trim string + return intval($time) * $multipel; + } + + /** + * Returns the contents of the script file if it exists and removes the UTF-8 BOM header if it exists. + * + * @param String $file File to load. + * @return String File contents or empty string if it doesn't exist. + */ + private function getFileContents($file) { + $content = file_get_contents($file); + + // Remove UTF-8 BOM + if (substr($content, 0, 3) === pack("CCC", 0xef, 0xbb, 0xbf)) { + $content = substr($content, 3); + } + + return $content; + } +} +?> \ No newline at end of file diff --git a/rsc/js/tiny_mce/tinymce.min.js b/rsc/ext/tiny_mce/tinymce.min.js similarity index 100% rename from rsc/js/tiny_mce/tinymce.min.js rename to rsc/ext/tiny_mce/tinymce.min.js diff --git a/rsc/js/src/twin-bcrypt.js b/rsc/ext/twin-bcrypt.js similarity index 100% rename from rsc/js/src/twin-bcrypt.js rename to rsc/ext/twin-bcrypt.js diff --git a/rsc/css/videojs/font/VideoJS.eot b/rsc/ext/videojs/css/font/VideoJS.eot similarity index 100% rename from rsc/css/videojs/font/VideoJS.eot rename to rsc/ext/videojs/css/font/VideoJS.eot diff --git a/rsc/css/videojs/font/VideoJS.svg b/rsc/ext/videojs/css/font/VideoJS.svg similarity index 100% rename from rsc/css/videojs/font/VideoJS.svg rename to rsc/ext/videojs/css/font/VideoJS.svg diff --git a/rsc/css/videojs/font/VideoJS.ttf b/rsc/ext/videojs/css/font/VideoJS.ttf similarity index 100% rename from rsc/css/videojs/font/VideoJS.ttf rename to rsc/ext/videojs/css/font/VideoJS.ttf diff --git a/rsc/css/videojs/font/VideoJS.woff b/rsc/ext/videojs/css/font/VideoJS.woff similarity index 100% rename from rsc/css/videojs/font/VideoJS.woff rename to rsc/ext/videojs/css/font/VideoJS.woff diff --git a/rsc/css/videojs/video-js.css b/rsc/ext/videojs/css/video-js.css similarity index 100% rename from rsc/css/videojs/video-js.css rename to rsc/ext/videojs/css/video-js.css diff --git a/rsc/css/videojs/video-js.min.css b/rsc/ext/videojs/css/video-js.min.css similarity index 100% rename from rsc/css/videojs/video-js.min.css rename to rsc/ext/videojs/css/video-js.min.css diff --git a/rsc/js/videojs/video.js b/rsc/ext/videojs/js/video.js similarity index 100% rename from rsc/js/videojs/video.js rename to rsc/ext/videojs/js/video.js diff --git a/rsc/js/videojs/video.min.js b/rsc/ext/videojs/js/video.min.js similarity index 100% rename from rsc/js/videojs/video.min.js rename to rsc/ext/videojs/js/video.min.js diff --git a/rsc/js/zxcvbn.js b/rsc/ext/zxcvbn.js similarity index 100% rename from rsc/js/zxcvbn.js rename to rsc/ext/zxcvbn.js diff --git a/rsc/js/backoffice.js b/rsc/js/backoffice.js index 580f4cde4c4..1b440ef8c6b 100644 --- a/rsc/js/backoffice.js +++ b/rsc/js/backoffice.js @@ -12,74 +12,6 @@ jQuery( document ).on( 'change', '.btn-file :file', function() } ); -/** - * Open or close a clickopen area (by use of CSS style). - * - * You have to define a div with id clickdiv_ and a img with clickimg_, - * where is the first param to the function. - * - * Used to expand/collapse in BACK-office: - * - _file.funcs.php: to toggle the subfolders in directory list - * - * @param string html id of the element to toggle - * @param string CSS display property to use when visible ('inline', 'block') - * @return false - */ -function toggle_clickopen( id, hide, displayVisible ) -{ - if( !( clickdiv = document.getElementById( 'clickdiv_'+id ) ) - || !( clickimg = document.getElementById( 'clickimg_'+id ) ) ) - { - alert( 'ID '+id+' not found!' ); - return false; - } - - if( typeof(hide) == 'undefined' ) - { - hide = clickdiv.style.display != 'none'; - } - - if( typeof(displayVisible) == 'undefined' ) - { - displayVisible = ''; // setting it to "empty" is the default for an element's display CSS attribute - } - - clickimg = jQuery( clickimg ); - if( clickimg.hasClass( 'fa' ) || clickimg.hasClass( 'glyphicon' ) ) - { // Fontawesome icon | Glyph bootstrap icon - if( clickimg.data( 'toggle' ) != '' ) - { // This icon has a class name to toggle - var icon_prefix = ( clickimg.hasClass( 'fa' ) ? 'fa' : 'glyphicon' ); - if( clickimg.data( 'toggle-orig-class' ) == undefined ) - { // Store original class name in data - clickimg.data( 'toggle-orig-class', clickimg.attr( 'class' ).replace( new RegExp( '^'+icon_prefix+' (.+)$', 'g' ), '$1' ) ); - } - if( clickimg.hasClass( clickimg.data( 'toggle-orig-class' ) ) ) - { // Replace original class name with exnpanded - clickimg.removeClass( clickimg.data( 'toggle-orig-class' ) ) - .addClass( icon_prefix + '-' + clickimg.data( 'toggle' ) ); - } - else - { // Revert back original class - clickimg.removeClass( icon_prefix + '-' + clickimg.data( 'toggle' ) ) - .addClass( clickimg.data( 'toggle-orig-class' ) ); - } - } - } - else - { // Sprite icon - var xy = clickimg.css( 'background-position' ).match( /-*\d+/g ); - // Shift background position to the right/left to the one icon in the sprite - clickimg.css( 'background-position', ( parseInt( xy[0] ) + ( hide ? 16 : - 16 ) ) + 'px ' + parseInt( xy[1] ) + 'px' ); - } - - // Hide/Show content block - clickdiv.style.display = hide ? 'none' : displayVisible; - - return false; -} - - /** * Fades the relevant object to provide feedback, in case of success. * @@ -402,28 +334,50 @@ function b2template_list_highlight( obj ) link_url += '&highlight=' + selected_template; } - if( window.self !== window.top ) + var new_target = link.attr('target'); + + if ( new_target === undefined ) { - window.top.location = link_url; + if( window.self !== window.top ) + { + window.top.location = link_url; + } + else + { + window.location = link_url; + } } else { - window.location = link_url; + window.open( link_url, new_target ); } + return false; -} +} /** * Copy text of element to clipboard * * @param string Element ID + * @param string Optional text, use this to copy instead of content of the Element */ -function evo_copy_to_clipboard( id ) +function evo_copy_to_clipboard( id, custom_text ) { + if( typeof( custom_text ) == 'undefined' ) + { // Copy text from Element: + var text_obj = document.getElementById( id ); + } + else + { // Copy a provided Text: + var text_obj = document.createElement( 'span' ); + text_obj.innerHTML = custom_text; + document.body.appendChild( text_obj ); + } + // Create range to select element by ID: var range = document.createRange(); - range.selectNode( document.getElementById( id ) ); + range.selectNode( text_obj ); // Clear current selection: window.getSelection().removeAllRanges(); // Select text of the element temporary: @@ -435,5 +389,10 @@ function evo_copy_to_clipboard( id ) // Highlight copied element: evoFadeBg( '#' + id, new Array( '#ffbf00' ), { speed: 100 } ); + if( typeof( custom_text ) != 'undefined' ) + { // Remove temp object what was used only for copying above: + document.body.removeChild( text_obj ); + } + return false; } \ No newline at end of file diff --git a/rsc/js/build/bootstrap-evo_backoffice.bmin.js b/rsc/js/build/bootstrap-evo_backoffice.bmin.js index b0275754a34..2fd2f663dbd 100644 --- a/rsc/js/build/bootstrap-evo_backoffice.bmin.js +++ b/rsc/js/build/bootstrap-evo_backoffice.bmin.js @@ -1,3 +1,3 @@ -/* This includes 22 files: functions.js, ajax.js, communication.js, form_extensions.js, extracats.js, dynamic_select.js, backoffice.js, blog_widgets.js, src/bootstrap-evo_modal_window.js, src/evo_images.js, src/evo_user_crop.js, src/evo_user_report.js, src/evo_user_deldata.js, src/evo_user_org.js, src/evo_automation.js, src/evo_user_tags.js, src/evo_user_status.js, src/evo_user_groups.js, src/evo_rest_api.js, src/evo_links.js, src/evo_forms.js, src/evo_input_counter.js */ +/* This includes 23 files: build/evo_generic.bmin.js, functions.js, ajax.js, communication.js, form_extensions.js, extracats.js, dynamic_select.js, backoffice.js, blog_widgets.js, src/bootstrap-evo_modal_window.js, src/evo_images.js, src/evo_user_crop.js, src/evo_user_report.js, src/evo_user_deldata.js, src/evo_user_org.js, src/evo_automation.js, src/evo_user_tags.js, src/evo_user_status.js, src/evo_user_groups.js, src/evo_rest_api.js, src/evo_links.js, src/evo_forms.js, src/evo_input_counter.js */ -function pop_up_window(e,t,a,r,n){return void 0===a&&(a=750),void 0===r&&(r=550),void 0===n&&(n="scrollbars=yes, status=yes, resizable=yes, menubar=yes"),n="width="+a+", height="+r+", left="+(screen.width-a)/2+", top="+(screen.height-r)/2+", "+n,opened=window.open(e,t,n),opened.focus(),"undefined"==typeof openedWindows?openedWindows=new Array(opened):openedWindows.push(opened),!1}function textarea_replace_selection(e,t,a){textarea_wrap_selection(e,t,"",1,a)}function textarea_wrap_selection(e,t,a,r,n){var o={element:e,before:t,after:a,replace:r,target_document:n=n||document};if(!b2evo_Callbacks.trigger_callback("wrap_selection_for_"+e.id,o)){if(window.opener&&void 0!==window.opener)try{if(window.opener.b2evo_Callbacks&&void 0!==window.opener.b2evo_Callbacks&&window.opener.b2evo_Callbacks.trigger_callback("wrap_selection_for_"+e.id,o))return}catch(e){}if(!(window.parent&&void 0!==window.parent&&window.parent.b2evo_Callbacks&&void 0!==window.parent.b2evo_Callbacks&&window.parent.b2evo_Callbacks.trigger_callback("wrap_selection_for_"+e.id,o)))if(n.selection)e.focus(),sel=n.selection.createRange(),sel.text=r?t+a:t+sel.text+a,e.focus();else if(e.selectionStart||"0"==e.selectionStart){var i,s,l,d=e.selectionStart,u=e.selectionEnd;"textarea"==e.type&&void 0!==e.scrollTop&&(s=e.scrollTop,l=e.scrollLeft),i=r?(e.value=e.value.substring(0,d)+t+a+e.value.substring(u,e.value.length),d+t.length+a.length):(e.value=e.value.substring(0,d)+t+e.value.substring(d,u)+a+e.value.substring(u,e.value.length),u+t.length+a.length),void 0!==s&&(e.scrollTop=s,e.scrollLeft=l),e.focus(),e.selectionStart=i,e.selectionEnd=i}else e.value+=t+a,e.focus()}}function textarea_str_replace(e,t,a,r){var n={element:e,search:t,replace:a,target_document:r=r||document};if(!b2evo_Callbacks.trigger_callback("str_replace_for_"+e.id,n)){if(window.opener&&void 0!==window.opener)try{if(window.opener.b2evo_Callbacks&&void 0!==window.opener.b2evo_Callbacks&&window.opener.b2evo_Callbacks.trigger_callback("str_replace_for_"+e.id,n))return}catch(e){}window.parent&&void 0!==window.parent&&window.parent.b2evo_Callbacks&&void 0!==window.parent.b2evo_Callbacks&&window.parent.b2evo_Callbacks.trigger_callback("str_replace_for_"+e.id,n)||(e.value=e.value.replace(t,a),e.focus())}}function toggle_filter_area(e,t){var a=jQuery("#clickdiv_"+e),r=jQuery("#clickimg_"+e);if(0==a.length||0==r.length)return alert("ID "+e+" not found!"),!1;if(r.hasClass("fa")||r.hasClass("glyphicon")){if(""!=r.data("toggle")&&null!=r.data("toggle")){var n=r.hasClass("fa")?"fa":"glyphicon";null==r.data("toggle-orig-class")&&r.data("toggle-orig-class",r.attr("class").replace(new RegExp("^"+n+" (.+)$","g"),"$1")),r.hasClass(r.data("toggle-orig-class"))?r.removeClass(r.data("toggle-orig-class")).addClass(n+"-"+r.data("toggle")):r.removeClass(n+"-"+r.data("toggle")).addClass(r.data("toggle-orig-class"))}}else{var o=r.css("background-position").match(/-*\d+/g);r.css("background-position",parseInt(o[0])+(a.is(":hidden")?-16:16)+"px "+parseInt(o[1])+"px")}var i=void 0===t?a.is(":hidden")?"expand":"collapse":t;return"collapse"==i?a.slideUp(500):"expand"==i&&a.slideDown(500),void 0===t&&"expand"==i&&jQuery("#clickdiv_"+e).closest(".filters").find("[id^=clickdiv_]").each(function(){jQuery(this).is(":visible")&&jQuery(this).attr("id")!="clickdiv_"+e&&toggle_filter_area(jQuery(this).attr("id").substr(9),"collapse")}),!1}function b2evo_Callbacks(){this.eventHandlers=new Array}b2evo_Callbacks.prototype={register_callback:function(e,t,a){void 0===this.eventHandlers[e]&&(this.eventHandlers[e]=new Array),void 0!==a&&a?this.eventHandlers[e][0]=t:this.eventHandlers[e][this.eventHandlers[e].length]=t},trigger_callback:function(event,args){if(void 0===this.eventHandlers[event])return null;for(var r=!1,cb_args="",cb_arguments=arguments,i=1;i'+e+"

    "),setTimeout(function(){jQuery(".b2evo_alert").fadeOut({complete:function(){jQuery(this).remove()}})},3e3),evo_alert_events_initialized||(evo_alert_events_initialized=!0,jQuery(document).on("click",".b2evo_alert",function(){jQuery(this).remove()}))}function debounce(n,o,i){var s,l;return function(){var e,t,a=this,r=arguments;return e=function(){s=null,i||(l=n.apply(a,r))},t=i&&!s,clearTimeout(s),s=setTimeout(e,o),t&&(l=n.apply(a,r)),l}}function ajax_debug_clear(e){return e=(e=e.replace(//,"")).replace(/(
    [\s\S]*)/i,""),jQuery.trim(e)}function ajax_response_is_correct(e){return!!e.match(//)&&""!=(e=ajax_debug_clear(e))}function SendAdminRequest(e,t,a,r){void 0!==r&&!r||(a+=(""!==a?"&":"")+"nocache_dummy="+(new Date).getTime());SendServerRequest(b2evo_dispatcher_url+"?ctrl="+e+"&action="+t+(a?"&"+a:""))}function SendServerRequest(e){e+=-1!=e.indexOf("?")?"&":"?";var t=(e+="display_mode=js").split("?");e=t[0],t=t[1],jQuery.ajax({type:"POST",url:e,data:t,dataType:"script",success:function(){-1').appendTo("#"+e),jQuery("#"+e).attr("target","server_postback")}function DisplayServerMessages(e,t){jQuery("#server_messages").html(e),"object"==typeof t&&(jQuery("input.field_error, select.field_error, textarea.field_error").each(function(){jQuery(this).removeClass("field_error");var e=jQuery(this).next();e.hasClass("notes")&&"SPAN"==e.get(0).tagName&&e.remove()}),jQuery.each(t,function(e,t){jQuery("#"+e).addClass("field_error").after(' '+t+"")})),jQuery("#server_messages .log_success").animate({backgroundColor:"#88ff88"},"fast").animate({backgroundColor:"#ffffff"},"fast","",function(){jQuery(this).removeAttr("style")}),jQuery("#server_messages > .log_error").animate({backgroundColor:"#ff8888"},"fast").animate({backgroundColor:"#ffffff"},"fast","",function(){jQuery(this).removeAttr("style")})}evo_alert_events_initialized=!1,jQuery(document).ready(function(){function a(e){var t=e.data("prefix")?e.data("prefix"):"",a=jQuery("."+t+e.val()+"_toolbar");if(0==a.length)return!0;e.is(":checked")?(a.removeClass("disabled"),a.find("input[type=button]").prop("disabled",!1)):(a.addClass("disabled"),a.find("input[type=button]").prop("disabled",!0))}jQuery(document).on("click","[data-func]",function(){var e=jQuery(this).data("func").match(/([^\\|]|\\\|)+/g),t=e[0];e.splice(0,1);for(var a=0;a
    ').prependTo(".pblock"):jQuery(".level2").length?jQuery(".level2").after('
    '):jQuery(".navbar.level1").after('
    '),jQuery('').appendTo("body").css({position:"absolute",left:"-1000em",top:"-1000em"})});var _b2evoCommunications=function(){var a,r,t=2500,n=250;return{Init:function(){var e=jQuery.fn.extend({delay:t,interval:n,dispatcher:r},arguments.length?arguments[0]:"");t=e.delay,n=e.interval,r=e.dispatcher,a=this,b2evoHelper.info("Communications object ready")},BufferedServerCall:function(){var e=jQuery.fn.extend({ticker_callback:function(){return!0},send_callback:function(){},delay:t,interval:n,buffer_name:""},arguments.length?arguments[0]:"");if(ticker_status=e.ticker_callback(e.delay))switch(!0!==ticker_status&&b2evoHelper.log("Ticker status : "+ticker_status),ticker_status){case"cancel":return void b2evoHelper.DisplayMessage('
    '+T_("Update cancelled")+"
    ");case"pause":return b2evoHelper.DisplayMessage('
    '+T_("Update Paused")+" : "+b2evoHelper.str_repeat(".",e.delay/e.interval)+"
    "),void a.BufferedServerLoop(e);case"ignore":return void a.BufferedServerLoop(e);case"immediate":break;default:if(e.delay-=e.interval,0'+T_("Changes pending")+" : "+b2evoHelper.str_repeat(".",e.delay/e.interval)+"
    "),void a.BufferedServerLoop(e);b2evoHelper.DisplayMessage('
    '+T_("Saving changes")+"
    "),e.send_callback()}},BufferedServerLoop:function(e){var t=jQuery(a).data("buffers");void 0===t&&(t=Array()),t[e.buffer_name]=e,jQuery(a).data("buffers",t),window.setTimeout('b2evoCommunications.BufferedServerCallback( "'+e.buffer_name+'" )',e.interval)},BufferedServerCallback:function(e){var t=jQuery(a).data("buffers");a.BufferedServerCall(t[e])},SendAdminRequest:function(){var e=jQuery.fn.extend({ctrl:"",action:"",data:"",key:"",error:function(){return!1},ok:function(){return!1}},arguments.length?arguments[0]:""),t="ctrl="+e.ctrl+"&key="+e.key+"&action="+e.action+"&"+e.data;a.SendServerRequest({url:r,data:t,error:e.error,ok:e.ok})},SendServerRequest:function(){var e=jQuery.fn.extend({url:"",data:"",error:function(){return!1},ok:function(){return!1}},arguments.length?arguments[0]:"");if(e.url){e.url+=(!0===e.url.indexOf("?")?"&":"?")+"mode=js",e.data&&(e.url+="&"+e.data);var t=jQuery(" + diff --git a/skins/bootstrap_forums_skin/_item_comment.inc.php b/skins/bootstrap_forums_skin/_item_comment.inc.php index 26dba4883b0..c58518efa5f 100644 --- a/skins/bootstrap_forums_skin/_item_comment.inc.php +++ b/skins/bootstrap_forums_skin/_item_comment.inc.php @@ -315,7 +315,7 @@ echo '
    '; $Comment->edit_link( ' ', '', '#', T_('Edit this reply'), button_class( 'text' ).' comment_edit_btn', '&', true, $comment_redirect_url ); /* Link for editing */ echo ''; - $delete_button_is_displayed = is_logged_in() && $current_User->check_perm( 'comment!CURSTATUS', 'delete', false, $Comment ); + $delete_button_is_displayed = check_user_perm( 'comment!CURSTATUS', 'delete', false, $Comment ); $Comment->moderation_links( array( 'ajax_button' => true, 'class' => button_class( 'text' ), diff --git a/skins/bootstrap_forums_skin/_item_content.inc.php b/skins/bootstrap_forums_skin/_item_content.inc.php index ff137966b6c..ba660b1bff7 100644 --- a/skins/bootstrap_forums_skin/_item_content.inc.php +++ b/skins/bootstrap_forums_skin/_item_content.inc.php @@ -123,7 +123,7 @@ if( $params['include_cover_images'] ) { // Include the cover images on teaser place - $teaser_image_positions = 'cover,teaser,teaserperm,teaserlink'; + $teaser_image_positions = 'cover,background,teaser,teaserperm,teaserlink'; } else { // Don't include the cover images @@ -162,7 +162,7 @@ 'gallery_image_limit' => $params['gallery_image_limit'], 'gallery_colls' => $params['gallery_colls'], 'gallery_order' => $params['gallery_order'], - // Optionally restrict to files/images linked to specific position: 'teaser'|'teaserperm'|'teaserlink'|'aftermore'|'inline'|'cover' + // Optionally restrict to files/images linked to specific position: 'teaser'|'teaserperm'|'teaserlink'|'aftermore'|'inline'|'cover'|'background' 'restrict_to_image_position' => $teaser_image_positions, ) ); } @@ -214,7 +214,7 @@ 'gallery_image_limit' => $params['gallery_image_limit'], 'gallery_colls' => $params['gallery_colls'], 'gallery_order' => $params['gallery_order'], - // Optionally restrict to files/images linked to specific position: 'teaser'|'teaserperm'|'teaserlink'|'aftermore'|'inline'|'cover' + // Optionally restrict to files/images linked to specific position: 'teaser'|'teaserperm'|'teaserlink'|'aftermore'|'inline'|'cover'|'background' 'restrict_to_image_position' => $teaser_image_positions, ) ); } @@ -291,7 +291,7 @@ 'gallery_image_limit' => $params['gallery_image_limit'], 'gallery_colls' => $params['gallery_colls'], 'gallery_order' => $params['gallery_order'], - // Optionally restrict to files/images linked to specific position: 'teaser'|'teaserperm'|'teaserlink'|'aftermore'|'inline'|'cover' + // Optionally restrict to files/images linked to specific position: 'teaser'|'teaserperm'|'teaserlink'|'aftermore'|'inline'|'cover'|'background' 'restrict_to_image_position' => 'aftermore', ) ); } diff --git a/skins/bootstrap_forums_skin/_item_list.inc.php b/skins/bootstrap_forums_skin/_item_list.inc.php index d15c74a8a4f..cbda4e26e95 100644 --- a/skins/bootstrap_forums_skin/_item_list.inc.php +++ b/skins/bootstrap_forums_skin/_item_list.inc.php @@ -65,12 +65,10 @@ } // There is a very restrictive case in which we display workflow: $display_workflow = - // User must be logged in: - is_logged_in() && // Workflow must be enabled for current Collection: $Item->get_coll_setting( 'use_workflow' ) && // Current User must has a permission to be assigned for tasks of the current Collection: - $current_User->check_perm( 'blog_can_be_assignee', 'edit', false, $Item->get_blog_ID() ); + check_user_perm( 'blog_can_be_assignee', 'edit', false, $Item->get_blog_ID() ); ?>
    diff --git a/skins/bootstrap_forums_skin/_posts.disp.php b/skins/bootstrap_forums_skin/_posts.disp.php index e2eb7aad6c7..c4caed1c1e8 100644 --- a/skins/bootstrap_forums_skin/_posts.disp.php +++ b/skins/bootstrap_forums_skin/_posts.disp.php @@ -64,17 +64,9 @@ $Item = & get_featured_Item( 'posts', NULL, false, ( isset( $tag ) || $single_cat_ID ? false : NULL ) ) ) { // We have a intro post to display: $featured_item_ID = $Item->ID; - $intro_item_style = ''; - $LinkOwner = new LinkItem( $Item ); - $LinkList = $LinkOwner->get_attachment_LinkList( 1, 'cover' ); - if( ! empty( $LinkList ) && - $Link = & $LinkList->get_next() && - $File = & $Link->get_File() && - $File->exists() && - $File->is_image() ) - { // Use cover image of intro-post as background: - $intro_item_style = 'background-image: url("'.$File->get_url().'")'; - } + // Use background position image of intro-post for background URL: + $background_image_url = $Item->get_cover_image_url( 'background' ); + $intro_item_style = $background_image_url ? 'background-image: url("'.$background_image_url.'")' : ''; // ---------------------- ITEM BLOCK INCLUDED HERE ------------------------ skin_include( '_item_block_intro.inc.php', array( 'content_mode' => 'full', // We want regular "full" content, even in category browsing: i-e no excerpt or thumbnail diff --git a/skins/bootstrap_forums_skin/_search.disp.php b/skins/bootstrap_forums_skin/_search.disp.php index 92ca5731153..a4d96301446 100644 --- a/skins/bootstrap_forums_skin/_search.disp.php +++ b/skins/bootstrap_forums_skin/_search.disp.php @@ -23,7 +23,7 @@ widget_container( 'search_area', array( // The following params will be used as defaults for widgets included in this container: 'container_display_if_empty' => false, // If no widget, don't display container at all - 'container_start' => '
    ', + 'container_start' => '
    ', 'container_end' => '
    ', 'block_start' => '
    ', 'block_end' => '
    ', diff --git a/skins/bootstrap_forums_skin/_skin.class.php b/skins/bootstrap_forums_skin/_skin.class.php index d248c45bf15..f940ab25b78 100644 --- a/skins/bootstrap_forums_skin/_skin.class.php +++ b/skins/bootstrap_forums_skin/_skin.class.php @@ -21,7 +21,7 @@ class bootstrap_forums_Skin extends Skin * Skin version * @var string */ - var $version = '7.1.7'; + var $version = '7.2.5'; /** * Do we want to use style.min.css instead of style.css ? @@ -131,6 +131,8 @@ function get_declared_containers() */ function get_param_definitions( $params ) { + global $Blog; + // Load for function get_available_thumb_sizes(): load_funcs( 'files/model/_image.funcs.php' ); @@ -150,10 +152,16 @@ function get_param_definitions( $params ) ), 'type' => 'select', ), + 'sidebar_general_affix' => array( + 'label' => T_('Fixed position for General Sidebar'), + 'note' => T_('Use affix to keep visible when scrolling down.'), + 'type' => 'checkbox', + 'defaultvalue' => 0, + ), 'layout_single' => array( 'label' => T_('Single Thread Layout'), 'note' => T_('Select skin layout for single threads') . ' (disp=single).', - 'defaultvalue' => 'no_sidebar', + 'defaultvalue' => isset( $Blog ) && $Blog->type == 'group' ? 'right_sidebar' : 'no_sidebar', 'options' => array( 'no_sidebar' => T_('No Sidebar'), 'left_sidebar' => T_('Left Sidebar'), @@ -161,6 +169,12 @@ function get_param_definitions( $params ) ), 'type' => 'select', ), + 'sidebar_single_affix' => array( + 'label' => T_('Fixed position for Single Sidebar'), + 'note' => T_('Use affix to keep visible when scrolling down.'), + 'type' => 'checkbox', + 'defaultvalue' => 1, + ), 'main_content_image_size' => array( 'label' => T_('Image size for main content'), 'note' => T_('Controls Aspect, Ratio and Standard Size'), @@ -168,12 +182,6 @@ function get_param_definitions( $params ) 'options' => get_available_thumb_sizes(), 'type' => 'select', ), - 'sidebar_single_affix' => array( - 'label' => T_('Sidebar Single'), - 'note' => T_('Use affix to keep visible when scrolling down.'), - 'type' => 'checkbox', - 'defaultvalue' => 1, - ), 'max_image_height' => array( 'label' => T_('Max image height'), 'input_suffix' => ' px ', @@ -412,14 +420,10 @@ function display_init() // Request some common features that the parent function (Skin::display_init()) knows how to provide: parent::display_init( array( - 'jquery', // Load jQuery - 'font_awesome', // Load Font Awesome (and use its icons as a priority over the Bootstrap glyphicons) - 'bootstrap', // Load Bootstrap (without 'bootstrap_theme_css') - 'bootstrap_evo_css', // Load the b2evo_base styles for Bootstrap (instead of the old b2evo_base styles) + 'superbundle', // Load general front-office JS + bundled jQuery and Bootstrap 'bootstrap_messages', // Initialize $Messages Class to use Bootstrap styles 'style_css', // Load the style.css file of the current skin 'colorbox', // Load Colorbox (a lightweight Lightbox alternative + customizations for b2evo) - 'bootstrap_init_tooltips', // Inline JS to init Bootstrap tooltips (E.g. on comment form for allowed file extensions) 'disp_auto', // Automatically include additional CSS and/or JS required by certain disps (replace with 'disp_off' to disable this) ) ); @@ -437,12 +441,12 @@ function display_init() if( in_array( $disp, array( 'single', 'page', 'comments' ) ) ) { // Load jquery UI to animate background color on change comment status or on vote - require_js( '#jqueryUI#', 'blog' ); + require_js_defer( '#jqueryUI#', 'blog' ); } if( in_array( $disp, array( 'single', 'page' ) ) ) { // Init JS to autcomplete the user logins: - require_js( '#bootstrap_typeahead#', 'blog' ); + require_js_defer( '#bootstrap_typeahead#', 'blog' ); init_autocomplete_login_js( 'blog', 'typeahead' ); // Initialize date picker for _item_expert.form.php: init_datepicker_js( 'blog' ); @@ -465,6 +469,12 @@ function display_init() // Init JS to affix Messages: init_affix_messages_js( $this->get_setting( 'message_affix_offset' ) ); + + if( ( $this->get_setting( 'sidebar_general_affix' ) && $this->is_visible_sidebar( true, 'general' ) ) || + ( $this->get_setting( 'sidebar_single_affix' ) && $this->is_visible_sidebar( true, 'single' ) ) ) + { // Init JS to fix sidebars on scroll down: + require_js_defer( 'src/evo_affix_sidebars.js', 'blog', false, '#', 'footerlines' ); + } } @@ -696,7 +706,7 @@ function get_template( $name ) { case 'cat_array_mode': // What category level use to display the items on disp=posts: - // - 'children' - Get items from current category and from all its sub-categories recirsively + // - 'children' - Get items from current category and from all its sub-categories recursively // - 'parent' - Get items ONLY from current category WITHOUT sub-categories return 'parent'; @@ -820,7 +830,7 @@ function display_comment_voting_panel( $Comment, $place, $params = array() ) */ function display_posts_list_header( $title, $params = array() ) { - global $Blog, $current_User; + global $Blog; $params = array_merge( array( 'actions' => '', @@ -838,20 +848,18 @@ function display_posts_list_header( $title, $params = array() ) 'after_workflow_header' => '
    ', 'before_workflow_title' => '
    ', 'after_workflow_title' => '
    ', - 'before_workflow_status' => '
    ', + 'before_workflow_status' => '
    ', 'after_workflow_status' => '
    ', - 'before_workflow_actions' => '
    ', + 'before_workflow_actions' => '
    ', 'after_workflow_actions' => '
    ', ), $params ); // Check if current User can view workflow properties: $can_view_workflow = - // User must be logged in: - is_logged_in() && // Workflow must be enabled for current Collection: $Blog->get_setting( 'use_workflow' ) && // Current User must has a permission to be assigned for tasks of the current Collection: - $current_User->check_perm( 'blog_can_be_assignee', 'edit', false, $Blog->ID ); + check_user_perm( 'blog_can_be_assignee', 'edit', false, $Blog->ID ); // Get template depending on permission of current User: $template = ( $can_view_workflow ? 'workflow' : 'normal' ); @@ -880,19 +888,7 @@ function display_posts_list_header( $title, $params = array() ) .'' .$ItemStatusCache->get_option_list( $status ) .''; - // JavaScript to reload page with new selected task status: - echo ''; + expose_var_to_js( 'evo_skin_bootstrap_forums__post_list_header', true ); echo $params['after_workflow_status']; } @@ -907,4 +903,4 @@ function display_posts_list_header( $title, $params = array() ) } } -?> \ No newline at end of file +?> diff --git a/skins/bootstrap_forums_skin/index.main.php b/skins/bootstrap_forums_skin/index.main.php index bcf007610fb..222e9a0e8de 100644 --- a/skins/bootstrap_forums_skin/index.main.php +++ b/skins/bootstrap_forums_skin/index.main.php @@ -168,11 +168,13 @@ 'title_after' => '', 'title_single_disp' => false, 'title_page_disp' => false, + 'title_widget_page_disp' => false, 'format' => 'htmlbody', 'category_text' => '', 'categories_text' => '', 'catdir_text' => '', - 'comments_text' => T_('Latest Replies'), + 'comments_text' => '', + 'search_text' => '', 'front_text' => '', 'posts_text' => '', 'flagged_text' => '', @@ -290,6 +292,7 @@ ?> @@ -482,124 +486,4 @@ // ------------------------- HTML FOOTER INCLUDED HERE -------------------------- skin_include( '_html_footer.inc.php' ); // ------------------------------- END OF FOOTER -------------------------------- - -if( $Skin->is_visible_sidebar( true, 'single' ) && $Skin->get_setting( 'sidebar_single_affix' ) ) -{ // Sidebar enabled, add script that will affix the sidebar: - $sidebar_offset = $Skin->get_setting( 'message_affix_offset' ) == '' ? 20 : $Skin->get_setting( 'message_affix_offset' ); - ?> - - +?> \ No newline at end of file diff --git a/skins/bootstrap_gallery_legacy/_catdir.disp.php b/skins/bootstrap_gallery_legacy/_catdir.disp.php index 588cc9943c0..05405268284 100644 --- a/skins/bootstrap_gallery_legacy/_catdir.disp.php +++ b/skins/bootstrap_gallery_legacy/_catdir.disp.php @@ -122,7 +122,7 @@ 'image_desc' => '', 'gallery_image_limit' => 0, // Don't use images from attached folders. 'limit' => 1, // Get only first attached image depending on position priority, see param below: - 'restrict_to_image_position' => 'cover,teaser,aftermore,inline', + 'restrict_to_image_position' => 'cover,background,teaser,aftermore,inline', 'get_rendered_attachments' => false, // Sort the attachments to get firstly "Cover", then "Teaser", and "After more" as last order 'links_sql_select' => ', CASE ' diff --git a/skins/bootstrap_gallery_legacy/_item_comment.inc.php b/skins/bootstrap_gallery_legacy/_item_comment.inc.php index a763674e5b6..b5c15fd3632 100644 --- a/skins/bootstrap_gallery_legacy/_item_comment.inc.php +++ b/skins/bootstrap_gallery_legacy/_item_comment.inc.php @@ -184,7 +184,7 @@ echo '
    '; $Comment->edit_link( ' ', '', '#', T_('Edit this reply'), button_class( 'text' ).' comment_edit_btn', '&', true, $comment_redirect_url ); /* Link for editing */ echo ''; - $delete_button_is_displayed = is_logged_in() && $current_User->check_perm( 'comment!CURSTATUS', 'delete', false, $Comment ); + $delete_button_is_displayed = check_user_perm( 'comment!CURSTATUS', 'delete', false, $Comment ); $Comment->moderation_links( array( 'text' => '#', 'ajax_button' => true, diff --git a/skins/bootstrap_gallery_legacy/_posts.disp.php b/skins/bootstrap_gallery_legacy/_posts.disp.php index 7ec32dd49a8..763a4227fb7 100644 --- a/skins/bootstrap_gallery_legacy/_posts.disp.php +++ b/skins/bootstrap_gallery_legacy/_posts.disp.php @@ -99,7 +99,7 @@ 'image_link_to' => 'single', 'image_desc' => '', 'limit' => 1, - 'restrict_to_image_position' => 'cover,teaser,aftermore,inline', + 'restrict_to_image_position' => 'cover,background,teaser,aftermore,inline', 'get_rendered_attachments' => false, // Sort the attachments to get firstly "Cover", then "Teaser", and "After more" as last order 'links_sql_select' => ', CASE ' diff --git a/skins/bootstrap_gallery_legacy/_skin.class.php b/skins/bootstrap_gallery_legacy/_skin.class.php index 30f553ab27e..49fa1eefa88 100644 --- a/skins/bootstrap_gallery_legacy/_skin.class.php +++ b/skins/bootstrap_gallery_legacy/_skin.class.php @@ -21,7 +21,7 @@ class bootstrap_gallery_legacy_Skin extends Skin * Skin version * @var string */ - var $version = '7.1.7'; + var $version = '7.2.5'; /** * Do we want to use style.min.css instead of style.css ? @@ -325,14 +325,10 @@ function display_init() // Request some common features that the parent function (Skin::display_init()) knows how to provide: parent::display_init( array( - 'jquery', // Load jQuery - 'font_awesome', // Load Font Awesome (and use its icons as a priority over the Bootstrap glyphicons) - 'bootstrap', // Load Bootstrap (without 'bootstrap_theme_css') - 'bootstrap_evo_css', // Load the b2evo_base styles for Bootstrap (instead of the old b2evo_base styles) + 'superbundle', // Load general front-office JS + bundled jQuery and Bootstrap 'bootstrap_messages', // Initialize $Messages Class to use Bootstrap styles 'style_css', // Load the style.css file of the current skin 'colorbox', // Load Colorbox (a lightweight Lightbox alternative + customizations for b2evo) - 'bootstrap_init_tooltips', // Inline JS to init Bootstrap tooltips (E.g. on comment form for allowed file extensions) 'disp_auto', // Automatically include additional CSS and/or JS required by certain disps (replace with 'disp_off' to disable this) ) ); @@ -353,8 +349,8 @@ function display_init() // Page link color: $this->dynamic_style_rule( 'page_link_color', '#skin_wrapper .container a:not(.btn .active) { color: $setting_value$ }'. - '#skin_wrapper ul li a:not(.btn) { color: $setting_value$ }'. - '#skin_wrapper ul li a:not(.btn) {background-color: transparent }'. + '#skin_wrapper ul:not(.nav) li a:not(.btn) { color: $setting_value$ }'. + '#skin_wrapper ul:not(.nav) li a:not(.btn) {background-color: transparent }'. '.ufld_icon_links a:not(.btn) {color: #fff !important}' ); // Current tab text color: diff --git a/skins/bootstrap_gallery_legacy/index.main.php b/skins/bootstrap_gallery_legacy/index.main.php index d91a2a4e1da..c20a93fdd60 100644 --- a/skins/bootstrap_gallery_legacy/index.main.php +++ b/skins/bootstrap_gallery_legacy/index.main.php @@ -22,7 +22,7 @@ // Do inits depending on current $disp: skin_init( $disp ); // TODO: move to Skin::display_init -require_js( 'functions.js', 'blog' ); // for opening popup window (comments) +require_js_defer( 'functions.js', 'blog' ); // for opening popup window (comments) // -------------------------- HTML HEADER INCLUDED HERE -------------------------- skin_include( '_html_header.inc.php', array( 'arcdir_text' => T_('Index'), @@ -136,12 +136,15 @@ 'title_none' => '', 'glue' => ' - ', 'title_single_disp' => false, + 'title_widget_page_disp' => false, 'format' => 'htmlbody', 'arcdir_text' => T_('Index'), 'catdir_text' => '', 'category_text' => T_('Gallery').': ', 'categories_text' => T_('Galleries').': ', 'user_text' => '', + 'comments_text' => '', + 'search_text' => '', 'display_edit_links' => ( $disp == 'edit' ), 'edit_links_template' => array( 'before' => '', diff --git a/skins/bootstrap_gallery_legacy/single.main.php b/skins/bootstrap_gallery_legacy/single.main.php index 440daca188e..e5b9b66fccc 100644 --- a/skins/bootstrap_gallery_legacy/single.main.php +++ b/skins/bootstrap_gallery_legacy/single.main.php @@ -22,7 +22,7 @@ // Do inits depending on current $disp: skin_init( $disp ); // TODO: move to Skin::display_init -require_js( 'functions.js', 'blog' ); // for opening popup window (comments) +require_js_defer( 'functions.js', 'blog' ); // for opening popup window (comments) // -------------------------- HTML HEADER INCLUDED HERE -------------------------- skin_include( '_html_header.inc.php', array( 'arcdir_text' => T_('Index'), diff --git a/skins/bootstrap_gallery_skin/_catdir.disp.php b/skins/bootstrap_gallery_skin/_catdir.disp.php index 01e804a763a..3fcf3084100 100644 --- a/skins/bootstrap_gallery_skin/_catdir.disp.php +++ b/skins/bootstrap_gallery_skin/_catdir.disp.php @@ -122,7 +122,7 @@ 'image_desc' => '', 'gallery_image_limit' => 0, // Don't use images from attached folders. 'limit' => 1, // Get only first attached image depending on position priority, see param below: - 'restrict_to_image_position' => 'cover,teaser,aftermore,inline', + 'restrict_to_image_position' => 'cover,background,teaser,aftermore,inline', 'get_rendered_attachments' => false, // Sort the attachments to get firstly "Cover", then "Teaser", and "After more" as last order 'links_sql_select' => ', CASE ' diff --git a/skins/bootstrap_gallery_skin/_item_comment.inc.php b/skins/bootstrap_gallery_skin/_item_comment.inc.php index cb0d6a544ca..3831c1c01fd 100644 --- a/skins/bootstrap_gallery_skin/_item_comment.inc.php +++ b/skins/bootstrap_gallery_skin/_item_comment.inc.php @@ -185,7 +185,7 @@ echo '
    '; $Comment->edit_link( ' ', '', '#', T_('Edit this reply'), button_class( 'text' ).' comment_edit_btn', '&', true, $comment_redirect_url ); /* Link for editing */ echo ''; - $delete_button_is_displayed = is_logged_in() && $current_User->check_perm( 'comment!CURSTATUS', 'delete', false, $Comment ); + $delete_button_is_displayed = check_user_perm( 'comment!CURSTATUS', 'delete', false, $Comment ); $Comment->moderation_links( array( 'text' => '#', 'ajax_button' => true, diff --git a/skins/bootstrap_gallery_skin/_item_content.inc.php b/skins/bootstrap_gallery_skin/_item_content.inc.php index 87816061f33..41e063d3245 100644 --- a/skins/bootstrap_gallery_skin/_item_content.inc.php +++ b/skins/bootstrap_gallery_skin/_item_content.inc.php @@ -125,7 +125,7 @@ if( $params['include_cover_images'] ) { // Include the cover images on teaser place - $teaser_image_positions = 'cover,teaser,teaserperm,teaserlink'; + $teaser_image_positions = 'cover,background,teaser,teaserperm,teaserlink'; } else { // Don't include the cover images @@ -164,7 +164,7 @@ 'gallery_image_limit' => $params['gallery_image_limit'], 'gallery_colls' => $params['gallery_colls'], 'gallery_order' => $params['gallery_order'], - // Optionally restrict to files/images linked to specific position: 'teaser'|'teaserperm'|'teaserlink'|'aftermore'|'inline'|'cover' + // Optionally restrict to files/images linked to specific position: 'teaser'|'teaserperm'|'teaserlink'|'aftermore'|'inline'|'cover'|'background' 'restrict_to_image_position' => $teaser_image_positions, ) ); } @@ -236,7 +236,7 @@ 'gallery_image_limit' => $params['gallery_image_limit'], 'gallery_colls' => $params['gallery_colls'], 'gallery_order' => $params['gallery_order'], - // Optionally restrict to files/images linked to specific position: 'teaser'|'teaserperm'|'teaserlink'|'aftermore'|'inline'|'cover' + // Optionally restrict to files/images linked to specific position: 'teaser'|'teaserperm'|'teaserlink'|'aftermore'|'inline'|'cover'|'background' 'restrict_to_image_position' => $teaser_image_positions, ) ); } @@ -313,7 +313,7 @@ 'gallery_image_limit' => $params['gallery_image_limit'], 'gallery_colls' => $params['gallery_colls'], 'gallery_order' => $params['gallery_order'], - // Optionally restrict to files/images linked to specific position: 'teaser'|'teaserperm'|'teaserlink'|'aftermore'|'inline'|'cover' + // Optionally restrict to files/images linked to specific position: 'teaser'|'teaserperm'|'teaserlink'|'aftermore'|'inline'|'cover'|'background' 'restrict_to_image_position' => 'aftermore', ) ); } diff --git a/skins/bootstrap_gallery_skin/_posts.disp.php b/skins/bootstrap_gallery_skin/_posts.disp.php index 846db831c82..5fcc67bbc0f 100644 --- a/skins/bootstrap_gallery_skin/_posts.disp.php +++ b/skins/bootstrap_gallery_skin/_posts.disp.php @@ -99,7 +99,7 @@ 'image_link_to' => 'single', 'image_desc' => '', 'limit' => 1, - 'restrict_to_image_position' => 'cover,teaser,aftermore,inline', + 'restrict_to_image_position' => 'cover,background,teaser,aftermore,inline', 'get_rendered_attachments' => false, // Sort the attachments to get firstly "Cover", then "Teaser", and "After more" as last order 'links_sql_select' => ', CASE ' diff --git a/skins/bootstrap_gallery_skin/_skin.class.php b/skins/bootstrap_gallery_skin/_skin.class.php index 3c167485f94..6727063d333 100644 --- a/skins/bootstrap_gallery_skin/_skin.class.php +++ b/skins/bootstrap_gallery_skin/_skin.class.php @@ -21,7 +21,7 @@ class bootstrap_gallery_Skin extends Skin * Skin version * @var string */ - var $version = '7.1.7'; + var $version = '7.2.5'; /** * Do we want to use style.min.css instead of style.css ? @@ -325,14 +325,10 @@ function display_init() // Request some common features that the parent function (Skin::display_init()) knows how to provide: parent::display_init( array( - 'jquery', // Load jQuery - 'font_awesome', // Load Font Awesome (and use its icons as a priority over the Bootstrap glyphicons) - 'bootstrap', // Load Bootstrap (without 'bootstrap_theme_css') - 'bootstrap_evo_css', // Load the b2evo_base styles for Bootstrap (instead of the old b2evo_base styles) + 'superbundle', // Load general front-office JS + bundled jQuery and Bootstrap 'bootstrap_messages', // Initialize $Messages Class to use Bootstrap styles 'style_css', // Load the style.css file of the current skin 'colorbox', // Load Colorbox (a lightweight Lightbox alternative + customizations for b2evo) - 'bootstrap_init_tooltips', // Inline JS to init Bootstrap tooltips (E.g. on comment form for allowed file extensions) 'disp_auto', // Automatically include additional CSS and/or JS required by certain disps (replace with 'disp_off' to disable this) ) ); @@ -353,8 +349,8 @@ function display_init() // Page link color: $this->dynamic_style_rule( 'page_link_color', '#skin_wrapper .container a:not(.btn .active) { color: $setting_value$ }'. - '#skin_wrapper ul li a:not(.btn) { color: $setting_value$ }'. - '#skin_wrapper ul li a:not(.btn) {background-color: transparent }'. + '#skin_wrapper ul:not(.nav) li a:not(.btn) { color: $setting_value$ }'. + '#skin_wrapper ul:not(.nav) li a:not(.btn) {background-color: transparent }'. '.ufld_icon_links a:not(.btn) {color: #fff !important}' ); // Current tab text color: diff --git a/skins/bootstrap_gallery_skin/index.main.php b/skins/bootstrap_gallery_skin/index.main.php index 11c2698b8fc..fb4b44f4d0c 100644 --- a/skins/bootstrap_gallery_skin/index.main.php +++ b/skins/bootstrap_gallery_skin/index.main.php @@ -22,7 +22,7 @@ // Do inits depending on current $disp: skin_init( $disp ); // TODO: move to Skin::display_init -require_js( 'functions.js', 'blog' ); // for opening popup window (comments) +require_js_defer( 'functions.js', 'blog' ); // for opening popup window (comments) // -------------------------- HTML HEADER INCLUDED HERE -------------------------- skin_include( '_html_header.inc.php', array( 'arcdir_text' => T_('Index'), @@ -136,12 +136,15 @@ 'title_none' => '', 'glue' => ' - ', 'title_single_disp' => false, + 'title_widget_page_disp' => false, 'format' => 'htmlbody', 'arcdir_text' => T_('Index'), 'catdir_text' => '', 'category_text' => T_('Gallery').': ', 'categories_text' => T_('Galleries').': ', 'user_text' => '', + 'comments_text' => '', + 'search_text' => '', 'display_edit_links' => ( $disp == 'edit' ), 'edit_links_template' => array( 'before' => '', diff --git a/skins/bootstrap_gallery_skin/single.main.php b/skins/bootstrap_gallery_skin/single.main.php index 510295d70d1..ccf3851048d 100644 --- a/skins/bootstrap_gallery_skin/single.main.php +++ b/skins/bootstrap_gallery_skin/single.main.php @@ -22,7 +22,7 @@ // Do inits depending on current $disp: skin_init( $disp ); // TODO: move to Skin::display_init -require_js( 'functions.js', 'blog' ); // for opening popup window (comments) +require_js_defer( 'functions.js', 'blog' ); // for opening popup window (comments) // -------------------------- HTML HEADER INCLUDED HERE -------------------------- skin_include( '_html_header.inc.php', array( 'arcdir_text' => T_('Index'), diff --git a/skins/bootstrap_main_skin/_skin.class.php b/skins/bootstrap_main_skin/_skin.class.php index e3f9f01fdf4..9f88bdb658f 100644 --- a/skins/bootstrap_main_skin/_skin.class.php +++ b/skins/bootstrap_main_skin/_skin.class.php @@ -21,7 +21,7 @@ class bootstrap_main_Skin extends Skin * Skin version * @var string */ - var $version = '7.1.7'; + var $version = '7.2.5'; /** * Do we want to use style.min.css instead of style.css ? @@ -388,14 +388,10 @@ function display_init() // Request some common features that the parent function (Skin::display_init()) knows how to provide: parent::display_init( array( - 'jquery', // Load jQuery - 'font_awesome', // Load Font Awesome (and use its icons as a priority over the Bootstrap glyphicons) - 'bootstrap', // Load Bootstrap (without 'bootstrap_theme_css') - 'bootstrap_evo_css', // Load the b2evo_base styles for Bootstrap (instead of the old b2evo_base styles) + 'superbundle', // Load general front-office JS + bundled jQuery and Bootstrap 'bootstrap_messages', // Initialize $Messages Class to use Bootstrap styles 'style_css', // Load the style.css file of the current skin 'colorbox', // Load Colorbox (a lightweight Lightbox alternative + customizations for b2evo) - 'bootstrap_init_tooltips', // Inline JS to init Bootstrap tooltips (E.g. on comment form for allowed file extensions) 'disp_auto', // Automatically include additional CSS and/or JS required by certain disps (replace with 'disp_off' to disable this) ) ); diff --git a/skins/bootstrap_main_skin/front.main.php b/skins/bootstrap_main_skin/front.main.php index b6926ae6e89..a28a74dc39c 100644 --- a/skins/bootstrap_main_skin/front.main.php +++ b/skins/bootstrap_main_skin/front.main.php @@ -94,6 +94,7 @@ 'glue' => ' - ', 'title_single_disp' => false, 'title_page_disp' => false, + 'title_widget_page_disp' => false, 'format' => 'htmlbody', 'register_text' => '', 'login_text' => '', @@ -102,6 +103,7 @@ 'msgform_text' => '', 'user_text' => '', 'users_text' => '', + 'comments_text' => '', ) ); // ----------------------------- END OF REQUEST TITLE ---------------------------- ?> @@ -309,42 +311,10 @@ - - require_js_defer( 'slidedown.init.js', true ); + // ---------------------------- SITE FOOTER INCLUDED HERE ---------------------------- // If site footers are enabled, they will be included here: siteskin_include( '_site_body_footer.inc.php' ); diff --git a/skins/bootstrap_main_skin/index.main.php b/skins/bootstrap_main_skin/index.main.php index 263f5b97e28..8ed44643aca 100644 --- a/skins/bootstrap_main_skin/index.main.php +++ b/skins/bootstrap_main_skin/index.main.php @@ -165,6 +165,7 @@ 'glue' => ' - ', 'title_single_disp' => false, 'title_page_disp' => false, + 'title_widget_page_disp' => false, 'format' => 'htmlbody', 'register_text' => '', 'login_text' => '', @@ -173,6 +174,9 @@ 'msgform_text' => '', 'user_text' => '', 'users_text' => '', + 'comments_text' => '', + 'search_text' => '', + 'posts_text' => '', 'display_edit_links' => ( $disp == 'edit' ), 'edit_links_template' => array( 'before' => '', @@ -188,17 +192,9 @@ // Go Grab the featured post: if( ! in_array( $disp, array( 'single', 'page' ) ) && $Item = & get_featured_Item() ) { // We have a featured/intro post to display: - $intro_item_style = ''; - $LinkOwner = new LinkItem( $Item ); - $LinkList = $LinkOwner->get_attachment_LinkList( 1, 'cover' ); - if( ! empty( $LinkList ) && - $Link = & $LinkList->get_next() && - $File = & $Link->get_File() && - $File->exists() && - $File->is_image() ) - { // Use cover image of intro-post as background: - $intro_item_style = 'background-image: url("'.$File->get_url().'")'; - } + // Use background position image of intro-post for background URL: + $background_image_url = $Item->get_cover_image_url( 'background' ); + $intro_item_style = $background_image_url ? 'background-image: url("'.$background_image_url.'")' : ''; // ---------------------- ITEM BLOCK INCLUDED HERE ------------------------ skin_include( '_item_block.inc.php', array( 'feature_block' => true, diff --git a/skins/bootstrap_main_skin/slidedown.init.js b/skins/bootstrap_main_skin/slidedown.init.js new file mode 100644 index 00000000000..5e51589d216 --- /dev/null +++ b/skins/bootstrap_main_skin/slidedown.init.js @@ -0,0 +1,43 @@ +/** + * This file initialize Slide Down + * + * This file is part of the evoCore framework - {@link http://evocore.net/} + * See also {@link https://github.com/b2evolution/b2evolution}. + * + * @license GNU GPL v2 - {@link http://b2evolution.net/about/gnu-gpl-license} + * + * @copyright (c)2003-2020 by Francois PLANQUE - {@link http://fplanque.com/} + */ + +// Smooth scroll to top: +jQuery( '#slide_button' ).on( 'click', function( event ) +{ + event.preventDefault(); + jQuery( 'body, html, #skin_wrapper' ).animate( { + scrollTop: jQuery( '#slide_destination' ).offset().top + 26 + }, 1000 ); +} ); + +jQuery( document ).ready( function() +{ + // Check if .slide-top div exists (used to name back-to-top button) + if( jQuery( '.slide-top' ).length ) { + // Scroll to Top + // This skin needs to override the default scroll-top script because the `height: 100%` and `overflow: hidden` both exist on disp=front + // ======================================================================== / + // hide or show the "scroll to top" link + jQuery( 'body, html, #skin_wrapper' ).scroll( function() + { + ( jQuery( this ).scrollTop() > offset ) ? jQuery( '.slide-top' ).addClass( 'slide-top-visible' ) : jQuery( '.slide-top' ).removeClass( 'slide-top-visible' ); + } ); + + // Smooth scroll to top + jQuery( '.slide-top' ).on( 'click', function( event ) + { + event.preventDefault(); + jQuery( "body, html, #skin_wrapper" ).animate( { + scrollTop: 0, + }, scroll_top_duration ); + } ); + } +} ); \ No newline at end of file diff --git a/skins/bootstrap_main_skin/style.less b/skins/bootstrap_main_skin/style.less index a1e89759883..8689193f099 100644 --- a/skins/bootstrap_main_skin/style.less +++ b/skins/bootstrap_main_skin/style.less @@ -25,9 +25,6 @@ margin-bottom: 0 !important; // When it's the last
  • of last
      of the each div, no martgin-bottom, because of regular widget margin-bottom } // .widget_core_menu_link - // .widget_core_msg_menu_link - // .widget_core_profile_menu_link - // .widget_core_flag_menu_link &[class$=_menu_link] { // Align center buttons: text-align: center; diff --git a/skins/bootstrap_manual_skin/_item_content.inc.php b/skins/bootstrap_manual_skin/_item_content.inc.php index 4e56f055d7c..e0997d743be 100644 --- a/skins/bootstrap_manual_skin/_item_content.inc.php +++ b/skins/bootstrap_manual_skin/_item_content.inc.php @@ -127,7 +127,7 @@ if( $params['include_cover_images'] ) { // Include the cover images on teaser place - $teaser_image_positions = 'cover,teaser,teaserperm,teaserlink'; + $teaser_image_positions = 'cover,background,teaser,teaserperm,teaserlink'; } else { // Don't include the cover images @@ -166,7 +166,7 @@ 'gallery_image_limit' => $params['gallery_image_limit'], 'gallery_colls' => $params['gallery_colls'], 'gallery_order' => $params['gallery_order'], - // Optionally restrict to files/images linked to specific position: 'teaser'|'teaserperm'|'teaserlink'|'aftermore'|'inline'|'cover' + // Optionally restrict to files/images linked to specific position: 'teaser'|'teaserperm'|'teaserlink'|'aftermore'|'inline'|'cover'|'background' 'restrict_to_image_position' => $teaser_image_positions, ) ); } @@ -219,7 +219,7 @@ 'gallery_image_limit' => $params['gallery_image_limit'], 'gallery_colls' => $params['gallery_colls'], 'gallery_order' => $params['gallery_order'], - // Optionally restrict to files/images linked to specific position: 'teaser'|'teaserperm'|'teaserlink'|'aftermore'|'inline'|'cover' + // Optionally restrict to files/images linked to specific position: 'teaser'|'teaserperm'|'teaserlink'|'aftermore'|'inline'|'cover'|'background' 'restrict_to_image_position' => $teaser_image_positions, ) ); } @@ -298,7 +298,7 @@ 'gallery_image_limit' => $params['gallery_image_limit'], 'gallery_colls' => $params['gallery_colls'], 'gallery_order' => $params['gallery_order'], - // Optionally restrict to files/images linked to specific position: 'teaser'|'teaserperm'|'teaserlink'|'aftermore'|'inline'|'cover' + // Optionally restrict to files/images linked to specific position: 'teaser'|'teaserperm'|'teaserlink'|'aftermore'|'inline'|'cover'|'background' 'restrict_to_image_position' => 'aftermore', ) ); } diff --git a/skins/bootstrap_manual_skin/_skin.class.php b/skins/bootstrap_manual_skin/_skin.class.php index 7a78d08d0cb..8a4de78f969 100644 --- a/skins/bootstrap_manual_skin/_skin.class.php +++ b/skins/bootstrap_manual_skin/_skin.class.php @@ -21,7 +21,7 @@ class bootstrap_manual_Skin extends Skin * Skin version * @var string */ - var $version = '7.1.7'; + var $version = '7.2.5'; /** * Do we want to use style.min.css instead of style.css ? @@ -304,14 +304,10 @@ function display_init() // Request some common features that the parent function (Skin::display_init()) knows how to provide: parent::display_init( array( - 'jquery', // Load jQuery - 'font_awesome', // Load Font Awesome (and use its icons as a priority over the Bootstrap glyphicons) - 'bootstrap', // Load Bootstrap (without 'bootstrap_theme_css') - 'bootstrap_evo_css', // Load the b2evo_base styles for Bootstrap (instead of the old b2evo_base styles) + 'superbundle', // Load general front-office JS + bundled jQuery and Bootstrap 'bootstrap_messages', // Initialize $Messages Class to use Bootstrap styles 'style_css', // Load the style.css file of the current skin 'colorbox', // Load Colorbox (a lightweight Lightbox alternative + customizations for b2evo) - 'bootstrap_init_tooltips', // Inline JS to init Bootstrap tooltips (E.g. on comment form for allowed file extensions) 'disp_auto', // Automatically include additional CSS and/or JS required by certain disps (replace with 'disp_off' to disable this) ) ); @@ -333,9 +329,6 @@ function display_init() case 'front': // Init star rating for intro posts: init_ratings_js( 'blog', true ); - - // Used to quick upload several files: - init_fileuploader_js( 'blog' ); break; case 'posts': @@ -353,15 +346,12 @@ function display_init() $bootstrap_manual_posts_text = $Chapter->get( 'name' ); } } - - // Used to quick upload several files for comment of intro post: - init_fileuploader_js( 'blog' ); break; } if( $this->is_side_navigation_visible() ) { // Include JS code for left navigation panel only when it is displayed: - $this->require_js( 'affix_sidebars.js' ); + require_js_defer( 'src/evo_affix_sidebars.js', 'blog', false, '#', 'footerlines' ); } // Init JS to affix Messages: diff --git a/skins/bootstrap_manual_skin/index.main.php b/skins/bootstrap_manual_skin/index.main.php index f1a5b212131..4f4cfed0b82 100644 --- a/skins/bootstrap_manual_skin/index.main.php +++ b/skins/bootstrap_manual_skin/index.main.php @@ -139,13 +139,13 @@ 'title_after' => '', 'title_single_disp' => false, 'title_page_disp' => false, + 'title_widget_page_disp' => false, 'format' => 'htmlbody', 'category_text' => '', 'categories_text' => '', 'catdir_text' => '', 'front_text' => '', - // Display default title only for tag page without intro Item: - 'posts_text' => ( isset( $tag ) && ! has_featured_Item() ? '#' : '' ), + 'posts_text' => '', 'flagged_text' => '', 'mustread_text' => '', 'register_text' => '', @@ -155,6 +155,8 @@ 'msgform_text' => '', 'user_text' => '', 'users_text' => '', + 'comments_text' => '', + 'search_text' => '', 'display_edit_links' => ( $disp == 'edit' ), 'edit_links_template' => array( 'before' => '', diff --git a/skins/bootstrap_manual_skin/style.css b/skins/bootstrap_manual_skin/style.css index 81ef3f3ce40..09b3f6cec8a 100644 --- a/skins/bootstrap_manual_skin/style.css +++ b/skins/bootstrap_manual_skin/style.css @@ -13,26 +13,6 @@ .evo_container__footer { padding-top: 30px; } -#evo_container__sidebar, -#evo_container__sidebar_2, -#evo_container__sidebar_single { - background: #FFF; -} -#evo_container__sidebar.fixed, -#evo_container__sidebar_2.fixed, -#evo_container__sidebar_single.fixed { - position: fixed; -} -@media (max-height: 800px), (max-width: 992px) { - #evo_container__sidebar.fixed, - #evo_container__sidebar_2.fixed, - #evo_container__sidebar_single.fixed { - position: static; - } - .fixed_spacer { - display: none; - } -} div.powered_by p { margin: 4px auto; } diff --git a/skins/bootstrap_manual_skin/style.less b/skins/bootstrap_manual_skin/style.less index 32fa363ee85..66a2ecdb5cb 100644 --- a/skins/bootstrap_manual_skin/style.less +++ b/skins/bootstrap_manual_skin/style.less @@ -17,25 +17,6 @@ padding-top: 30px; } -// -------------------------- Sidebars -------------------------- -#evo_container__sidebar, #evo_container__sidebar_2, #evo_container__sidebar_single { - background: #FFF; - &.fixed { - position: fixed; - } -} -// Don't fix a position of ALL sidebars when window height <= 800px OR width <= 992px: -@media (max-height:800px),(max-width:992px) { - #evo_container__sidebar, #evo_container__sidebar_2, #evo_container__sidebar_single { - &.fixed { - position: static; - } - } - .fixed_spacer { - display: none; - } -} - // Powered-by logo. div.powered_by p { // border: 1px solid red; diff --git a/skins/bootstrap_manual_skin/style.min.css b/skins/bootstrap_manual_skin/style.min.css index b5d90376c88..f10b5ba089f 100644 --- a/skins/bootstrap_manual_skin/style.min.css +++ b/skins/bootstrap_manual_skin/style.min.css @@ -1 +1 @@ -#header{margin-bottom:20px}.evo_container__page_top{margin-top:20px}.evo_container__page_top .ufld_icon_links{text-align:right}.nav.nav-tabs{margin-top:0}.evo_container__footer{padding-top:30px}#evo_container__sidebar,#evo_container__sidebar_2,#evo_container__sidebar_single{background:#fff}#evo_container__sidebar.fixed,#evo_container__sidebar_2.fixed,#evo_container__sidebar_single.fixed{position:fixed}@media (max-height:800px),(max-width:992px){#evo_container__sidebar.fixed,#evo_container__sidebar_2.fixed,#evo_container__sidebar_single.fixed{position:static}.fixed_spacer{display:none}}div.powered_by p{margin:4px auto}ul.profile_tabs{margin:0 2ex 2ex;position:relative;top:1px}.profile_avatar{float:right;padding:10px;margin-left:10px}.form-horizontal .controls textarea.form-control{width:100%}input.search_field{margin-bottom:0;display:inline-block}form.search .search_options{width:100%}form.search .search_options .search_option input{margin-right:5px}form.search .search_options .search_option label{margin-bottom:0;margin-top:5px}div.compact_search_form input.search_field{width:100%;margin:0}div.extended_search_form{text-align:center;margin:0 auto 2em auto;max-width:530px}div.extended_search_form .search_options{text-align:center}div.extended_search_form .search_options .search_option{display:inline-block;margin-right:10px}textarea.message_text{width:95%}.evo_post{margin-bottom:2em}div.bSideItem{background:#f7f5fa;border-radius:5px;padding:10px;margin-bottom:10px;text-shadow:0 1px 0 #fff}div.bSideItem h4{margin-top:0}.pager{margin-bottom:0}.skin-form .panel-body .panel{border:none;box-shadow:none}.skin-form .panel-body .panel-body{padding:0}.skin-form .fieldset{margin:0}.skin-form .fieldset div.input{margin:0}.skin-form .control-buttons,.skin-form div.input{padding:0;width:100%;text-align:center}.evo_panel__activation,.evo_panel__login,.evo_panel__lostpass,.evo_panel__register{min-width:290px;margin:1.5em auto auto}.evo_panel__activation .panel,.evo_panel__login .panel,.evo_panel__lostpass .panel,.evo_panel__register .panel{margin:5px 0}.evo_panel__activation .panel-body,.evo_panel__login .panel-body,.evo_panel__lostpass .panel-body,.evo_panel__register .panel-body{padding-top:20px;padding-bottom:0}.evo_panel__login{max-width:400px;min-width:auto}.evo_panel__lostpass{max-width:480px}.evo_panel__lostpass #ffield_x label{display:none}.evo_panel__activation{max-width:530px}.evo_panel__activation #activateinfo_form .control-buttons{text-align:left}.evo_panel__register{max-width:580px}.evo_panel__register .form-control#country,.evo_panel__register .form-control#u{width:100%}.evo_panel__register #fieldset_wrapper_captcha_qstn .panel{margin:0}.evo_panel__register #fieldset_wrapper_captcha_qstn .panel div[id$=_answer] .control-label{padding-right:14px}.evo_panel__register .panel-body{padding:15px}.evo_panel__register .panel-body p:last-child{margin-bottom:0}@media (min-width:768px){#fieldset_wrapper_captcha_qstn .panel div[id$=_answer]{max-height:34px}}.evo_register_buttons{text-align:center}.evo_register_buttons input.btn{margin:0 0 15px 0}.evo_register_buttons a.btn{margin:0}.evo_form__login_links{padding:0 5px;font-size:92%}.evo_form__login fieldset{margin-bottom:20px}.evo_form__login .controls{padding:0;margin:0;width:100%}.evo_form__login .control-buttons{margin-left:0}.evo_form__login input.form-control[type=password],.evo_form__login input.form-control[type=text]{width:100%}.evo_form__login .btn{margin-top:5px}#login_form .control-buttons{text-align:left}.standard_login_link{text-align:center;margin:3em 0 1ex 0}.form_footer_notes{margin-top:0}.pagination{margin:15px}.filter_item div{height:22px}div.action_messages,div.log_container{margin:0}.chapters_list ul{margin:0 0 0 20px;list-style:none}.chapters_list li{list-style:none}.chapters_list li.selected>a.link,.chapters_list li.selected>i>a.link{color:#333;font-weight:700}.chapters_list a.link{padding:5px 0;display:inline-block}.chapters_list,.posts_list{list-style:none;margin:0}.chapters_list .link .fa,.posts_list .link .fa{margin-right:5px;font-size:inherit;width:auto!important}.posts_list h3{display:inline-block}.posts_list h3 .evo_post_flag_btn{font-size:inherit}.posts_list h3 .evo_post_flag_btn span.fa{font-size:inherit;margin-right:5px}.posts_list h3+.btn{margin:-10px 0 0 30px}.posts_list h3 .evo_post_read_status{text-decoration:none;display:inline-block;vertical-align:middle;font-size:85%;margin-top:-10px}.posts_list .evo_container__item_in_list .widget_core_item_title>.btn-group,.posts_list .evo_container__item_in_list .widget_core_item_title>.evo_status,.posts_list li>.btn-group,.posts_list li>.evo_status{margin:-6px 0 0 30px}ol.breadcrumb{margin-left:0}ol.breadcrumb img{margin-top:-2px}.cat_title,.evo_post_title{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-wrap:wrap;flex-wrap:wrap}.cat_title h1,.evo_post_title h1{margin:0;padding:20px 0 10px}.cat_title .btn-group,.evo_post_title .btn-group{padding:20px 0 10px 30px;white-space:nowrap}.cat_title .btn-group .btn,.evo_post_title .btn-group .btn{float:none}@media (max-width:767px){.cat_title,.evo_post_title{display:block}.cat_title h1,.evo_post_title h1{display:block}.cat_title .btn-group,.evo_post_title .btn-group{display:block;text-align:right;padding:0 0 10px 0}}.evo_content_block .evo_comment .evo_comment_footer .action_btn_group{float:right}.evo_content_block .evo_comment .comment_edit_btn{margin-right:5px}.evo_content_block .evo_comment .btn-group>.btn.first-child{border-top-left-radius:3px!important;border-bottom-left-radius:3px!important}.widget_core_coll_featured_intro .featurepost{background-color:#d9edf7;padding:15px 15px 25px;margin-bottom:20px;border:1px solid #e3e3e3;border-radius:4px;box-shadow:inset 0 1px 1px rgba(0,0,0,.05)} \ No newline at end of file +#header{margin-bottom:20px}.evo_container__page_top{margin-top:20px}.evo_container__page_top .ufld_icon_links{text-align:right}.nav.nav-tabs{margin-top:0}.evo_container__footer{padding-top:30px}div.powered_by p{margin:4px auto}ul.profile_tabs{margin:0 2ex 2ex;position:relative;top:1px}.profile_avatar{float:right;padding:10px;margin-left:10px}.form-horizontal .controls textarea.form-control{width:100%}input.search_field{margin-bottom:0;display:inline-block}form.search .search_options{width:100%}form.search .search_options .search_option input{margin-right:5px}form.search .search_options .search_option label{margin-bottom:0;margin-top:5px}div.compact_search_form input.search_field{width:100%;margin:0}div.extended_search_form{text-align:center;margin:0 auto 2em auto;max-width:530px}div.extended_search_form .search_options{text-align:center}div.extended_search_form .search_options .search_option{display:inline-block;margin-right:10px}textarea.message_text{width:95%}.evo_post{margin-bottom:2em}div.bSideItem{background:#f7f5fa;border-radius:5px;padding:10px;margin-bottom:10px;text-shadow:0 1px 0 #fff}div.bSideItem h4{margin-top:0}.pager{margin-bottom:0}.skin-form .panel-body .panel{border:none;box-shadow:none}.skin-form .panel-body .panel-body{padding:0}.skin-form .fieldset{margin:0}.skin-form .fieldset div.input{margin:0}.skin-form .control-buttons,.skin-form div.input{padding:0;width:100%;text-align:center}.evo_panel__activation,.evo_panel__login,.evo_panel__lostpass,.evo_panel__register{min-width:290px;margin:1.5em auto auto}.evo_panel__activation .panel,.evo_panel__login .panel,.evo_panel__lostpass .panel,.evo_panel__register .panel{margin:5px 0}.evo_panel__activation .panel-body,.evo_panel__login .panel-body,.evo_panel__lostpass .panel-body,.evo_panel__register .panel-body{padding-top:20px;padding-bottom:0}.evo_panel__login{max-width:400px;min-width:auto}.evo_panel__lostpass{max-width:480px}.evo_panel__lostpass #ffield_x label{display:none}.evo_panel__activation{max-width:530px}.evo_panel__activation #activateinfo_form .control-buttons{text-align:left}.evo_panel__register{max-width:580px}.evo_panel__register .form-control#country,.evo_panel__register .form-control#u{width:100%}.evo_panel__register #fieldset_wrapper_captcha_qstn .panel{margin:0}.evo_panel__register #fieldset_wrapper_captcha_qstn .panel div[id$=_answer] .control-label{padding-right:14px}.evo_panel__register .panel-body{padding:15px}.evo_panel__register .panel-body p:last-child{margin-bottom:0}@media (min-width:768px){#fieldset_wrapper_captcha_qstn .panel div[id$=_answer]{max-height:34px}}.evo_register_buttons{text-align:center}.evo_register_buttons input.btn{margin:0 0 15px 0}.evo_register_buttons a.btn{margin:0}.evo_form__login_links{padding:0 5px;font-size:92%}.evo_form__login fieldset{margin-bottom:20px}.evo_form__login .controls{padding:0;margin:0;width:100%}.evo_form__login .control-buttons{margin-left:0}.evo_form__login input.form-control[type=password],.evo_form__login input.form-control[type=text]{width:100%}.evo_form__login .btn{margin-top:5px}#login_form .control-buttons{text-align:left}.standard_login_link{text-align:center;margin:3em 0 1ex 0}.form_footer_notes{margin-top:0}.pagination{margin:15px}.filter_item div{height:22px}div.action_messages,div.log_container{margin:0}.chapters_list ul{margin:0 0 0 20px;list-style:none}.chapters_list li{list-style:none}.chapters_list li.selected>a.link,.chapters_list li.selected>i>a.link{color:#333;font-weight:700}.chapters_list a.link{padding:5px 0;display:inline-block}.chapters_list,.posts_list{list-style:none;margin:0}.chapters_list .link .fa,.posts_list .link .fa{margin-right:5px;font-size:inherit;width:auto!important}.posts_list h3{display:inline-block}.posts_list h3 .evo_post_flag_btn{font-size:inherit}.posts_list h3 .evo_post_flag_btn span.fa{font-size:inherit;margin-right:5px}.posts_list h3+.btn{margin:-10px 0 0 30px}.posts_list h3 .evo_post_read_status{text-decoration:none;display:inline-block;vertical-align:middle;font-size:85%;margin-top:-10px}.posts_list .evo_container__item_in_list .widget_core_item_title>.btn-group,.posts_list .evo_container__item_in_list .widget_core_item_title>.evo_status,.posts_list li>.btn-group,.posts_list li>.evo_status{margin:-6px 0 0 30px}ol.breadcrumb{margin-left:0}ol.breadcrumb img{margin-top:-2px}.cat_title,.evo_post_title{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-wrap:wrap;flex-wrap:wrap}.cat_title h1,.evo_post_title h1{margin:0;padding:20px 0 10px}.cat_title .btn-group,.evo_post_title .btn-group{padding:20px 0 10px 30px;white-space:nowrap}.cat_title .btn-group .btn,.evo_post_title .btn-group .btn{float:none}@media (max-width:767px){.cat_title,.evo_post_title{display:block}.cat_title h1,.evo_post_title h1{display:block}.cat_title .btn-group,.evo_post_title .btn-group{display:block;text-align:right;padding:0 0 10px 0}}.evo_content_block .evo_comment .evo_comment_footer .action_btn_group{float:right}.evo_content_block .evo_comment .comment_edit_btn{margin-right:5px}.evo_content_block .evo_comment .btn-group>.btn.first-child{border-top-left-radius:3px!important;border-bottom-left-radius:3px!important}.widget_core_coll_featured_intro .featurepost{background-color:#d9edf7;padding:15px 15px 25px;margin-bottom:20px;border:1px solid #e3e3e3;border-radius:4px;box-shadow:inset 0 1px 1px rgba(0,0,0,.05)} \ No newline at end of file diff --git a/skins/bootstrap_photoblog_skin/_catdir.disp.php b/skins/bootstrap_photoblog_skin/_catdir.disp.php index 32a5a5fd3b9..573d082cb28 100644 --- a/skins/bootstrap_photoblog_skin/_catdir.disp.php +++ b/skins/bootstrap_photoblog_skin/_catdir.disp.php @@ -78,7 +78,7 @@ 'image_desc' => '', 'gallery_image_limit' => 0, // Don't use images from attached folders. 'limit' => 1, // Get only first attached image depending on position priority, see param below: - 'restrict_to_image_position' => 'cover,teaser,aftermore,inline', + 'restrict_to_image_position' => 'cover,background,teaser,aftermore,inline', 'get_rendered_attachments' => false, // Sort the attachments to get firstly "Cover", then "Teaser", and "After more" as last order 'links_sql_select' => ', CASE ' diff --git a/skins/bootstrap_photoblog_skin/_item_block.inc.php b/skins/bootstrap_photoblog_skin/_item_block.inc.php index b10694304f9..12d7f56c584 100644 --- a/skins/bootstrap_photoblog_skin/_item_block.inc.php +++ b/skins/bootstrap_photoblog_skin/_item_block.inc.php @@ -71,7 +71,7 @@ 'gallery_colls' => 5, 'gallery_order' => '', // Can be 'ASC', 'DESC', 'RAND' or empty - // Optionally restrict to files/images linked to specific position: 'teaser'|'teaserperm'|'teaserlink'|'aftermore'|'inline'|'cover' + // Optionally restrict to files/images linked to specific position: 'teaser'|'teaserperm'|'teaserlink'|'aftermore'|'inline'|'cover'|'background' 'restrict_to_image_position' => 'teaser', ) ); ?> diff --git a/skins/bootstrap_photoblog_skin/_item_content.inc.php b/skins/bootstrap_photoblog_skin/_item_content.inc.php index 9665f3e6717..01f1ed2a56f 100644 --- a/skins/bootstrap_photoblog_skin/_item_content.inc.php +++ b/skins/bootstrap_photoblog_skin/_item_content.inc.php @@ -124,7 +124,7 @@ if( $params['include_cover_images'] ) { // Include the cover images on teaser place - $teaser_image_positions = 'cover,teaser,teaserperm,teaserlink'; + $teaser_image_positions = 'cover,background,teaser,teaserperm,teaserlink'; } else { // Don't include the cover images diff --git a/skins/bootstrap_photoblog_skin/_skin.class.php b/skins/bootstrap_photoblog_skin/_skin.class.php index 0d3691c125e..d4a5e27dd9d 100644 --- a/skins/bootstrap_photoblog_skin/_skin.class.php +++ b/skins/bootstrap_photoblog_skin/_skin.class.php @@ -21,7 +21,7 @@ class bootstrap_photoblog_Skin extends Skin * Skin version * @var string */ - var $version = '7.1.7'; + var $version = '7.2.5'; /** * Do we want to use style.min.css instead of style.css ? @@ -371,14 +371,10 @@ function display_init() // Request some common features that the parent function (Skin::display_init()) knows how to provide: parent::display_init( array( - 'jquery', // Load jQuery - 'font_awesome', // Load Font Awesome (and use its icons as a priority over the Bootstrap glyphicons) - 'bootstrap', // Load Bootstrap (without 'bootstrap_theme_css') - 'bootstrap_evo_css', // Load the b2evo_base styles for Bootstrap (instead of the old b2evo_base styles) + 'superbundle', // Load general front-office JS + bundled jQuery and Bootstrap 'bootstrap_messages', // Initialize $Messages Class to use Bootstrap styles 'style_css', // Load the style.css file of the current skin 'colorbox', // Load Colorbox (a lightweight Lightbox alternative + customizations for b2evo) - 'bootstrap_init_tooltips', // Inline JS to init Bootstrap tooltips (E.g. on comment form for allowed file extensions) 'disp_auto', // Automatically include additional CSS and/or JS required by certain disps (replace with 'disp_off' to disable this) ) ); diff --git a/skins/bootstrap_photoblog_skin/index.main.php b/skins/bootstrap_photoblog_skin/index.main.php index 10c9dd775fa..c9968ba6b4a 100644 --- a/skins/bootstrap_photoblog_skin/index.main.php +++ b/skins/bootstrap_photoblog_skin/index.main.php @@ -146,6 +146,7 @@ 'glue' => ' - ', 'title_single_disp' => false, 'title_page_disp' => false, + 'title_widget_page_disp' => false, 'format' => 'htmlbody', 'register_text' => '', 'login_text' => '', @@ -154,6 +155,8 @@ 'msgform_text' => '', 'user_text' => '', 'users_text' => '', + 'comments_text' => '', + 'search_text' => '', 'display_edit_links' => ( $disp == 'edit' ), 'edit_links_template' => array( 'before' => '', diff --git a/skins/bootstrap_photoblog_skin/style.css b/skins/bootstrap_photoblog_skin/style.css index 8253ce46d30..27d60841f30 100644 --- a/skins/bootstrap_photoblog_skin/style.css +++ b/skins/bootstrap_photoblog_skin/style.css @@ -84,7 +84,7 @@ div.widget_uil_autotemp.evo_1pic__special ul li .item_first_image_placeholder { margin-right: 6px; border-radius: 3px; } -div.widget_uil_autotemp.evo_1pic__special ul li .item_first_image_placeholder:before { +div.widget_uil_autotemp.evo_1pic__special ul li .item_first_image_placeholder::before { font-family: FontAwesome; display: table-cell; content: '\f0f6'; diff --git a/skins/bootstrap_photoblog_skin/style.min.css b/skins/bootstrap_photoblog_skin/style.min.css index d56b526f06d..fc8fc5eca88 100644 --- a/skins/bootstrap_photoblog_skin/style.min.css +++ b/skins/bootstrap_photoblog_skin/style.min.css @@ -1 +1 @@ -div.widget_uil_autotemp.evo_layout_flow .widget_flow_blocks{display:inline-block;text-align:center;width:100%}div.widget_uil_autotemp.evo_layout_flow .widget_flow_blocks>div{padding:8px;margin:14px;overflow:hidden;background-color:#fafafa;border-radius:4px;text-align:left;width:250px;display:inline-block;float:none;vertical-align:top}div.widget_uil_autotemp.evo_layout_flow.evo_withexcerpt .widget_flow_blocks>div .item_title,div.widget_uil_autotemp.evo_layout_flow.evo_withteaser .widget_flow_blocks>div .item_title{font-size:16px;font-weight:700;line-height:1.5em;margin:10px 0 5px}div.widget_uil_autotemp.evo_layout_rwd .widget_rwd_content{padding:8px;margin:14px 0;overflow:hidden;background-color:#fafafa;border-radius:4px}div.widget_uil_autotemp.evo_layout_rwd.evo_withexcerpt .widget_rwd_blocks>div,div.widget_uil_autotemp.evo_layout_rwd.evo_withteaser .widget_rwd_blocks>div{display:inline-block;float:none;vertical-align:top}div.widget_uil_autotemp.evo_layout_rwd.evo_withexcerpt .widget_rwd_blocks .widget_rwd_content .item_first_image img,div.widget_uil_autotemp.evo_layout_rwd.evo_withteaser .widget_rwd_blocks .widget_rwd_content .item_first_image img{width:100%;height:240px;object-fit:cover;margin:auto}div.widget_uil_autotemp.evo_layout_rwd.evo_withexcerpt .widget_rwd_blocks .widget_rwd_content .item_title,div.widget_uil_autotemp.evo_layout_rwd.evo_withteaser .widget_rwd_blocks .widget_rwd_content .item_title{font-size:16px;font-weight:700;line-height:1.5em;margin:10px 0 5px}div.widget_uil_autotemp.evo_layout_rwd.evo_withexcerpt .widget_rwd_blocks .widget_rwd_content .item_content>p:last-of-type,div.widget_uil_autotemp.evo_layout_rwd.evo_withteaser .widget_rwd_blocks .widget_rwd_content .item_content>p:last-of-type{min-height:60px;margin-bottom:0}div.widget_uil_autotemp.evo_layout_rwd.evo_withexcerpt .widget_rwd_blocks .widget_rwd_content .item_content a,div.widget_uil_autotemp.evo_layout_rwd.evo_withteaser .widget_rwd_blocks .widget_rwd_content .item_content a{margin:-20px 0 0}div.widget_uil_autotemp.evo_1pic__special h2{font-size:30px}div.widget_uil_autotemp.evo_1pic__special ul{padding:0;margin-left:0}div.widget_uil_autotemp.evo_1pic__special ul li{list-style:none;height:auto;display:inline-block;width:100%;clear:both;margin:5px 0;padding:0;vertical-align:middle}div.widget_uil_autotemp.evo_1pic__special ul li .item_first_image_placeholder{display:table;float:left;max-width:380px;max-height:380px;background:#f0f0f0;margin-right:6px;border-radius:3px}div.widget_uil_autotemp.evo_1pic__special ul li .item_first_image_placeholder:before{font-family:FontAwesome;display:table-cell;content:'\f0f6';color:#dcdcdc;font-size:40px;vertical-align:middle;text-align:center}div.widget_uil_autotemp.evo_1pic__special ul li div.item_title{vertical-align:middle;height:80px;display:-webkit-box;display:table-cell;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;text-overflow:ellipsis}div.widget_uil_autotemp.evo_1pic__special.evo_noexcerpt.evo_noteaser div.item_title a{font-size:22px}div.widget_uil_autotemp.evo_layout_list div.item_first_image{float:left;margin-right:6px}div.widget_uil_autotemp.evo_pics div.item_images{display:inline-block}div.widget_uil_autotemp.evo_pics div.item_images img{margin:6px 6px 0 0}div.widget_uil_autotemp.evo_pics.evo_1pic__special li{display:block;width:100%}div.widget_uil_autotemp.evo_pics.evo_1pic__special div.item_images{float:left}div.widget_uil_autotemp.evo_withexcerpt.evo_1pic__special ul li,div.widget_uil_autotemp.evo_withteaser.evo_1pic__special ul li{list-style:none;display:table}div.widget_uil_autotemp.evo_withexcerpt.evo_1pic__special ul li div.item_title a,div.widget_uil_autotemp.evo_withteaser.evo_1pic__special ul li div.item_title a{text-decoration:underline}div.widget_uil_autotemp.evo_withexcerpt.evo_1pic__special ul li div.item_content blockquote,div.widget_uil_autotemp.evo_withteaser.evo_1pic__special ul li div.item_content blockquote{margin-left:86px}div.widget_uil_autotemp.evo_withexcerpt.evo_1pic__special ul li div.item_excerpt,div.widget_uil_autotemp.evo_withteaser.evo_1pic__special ul li div.item_excerpt{margin-top:-2px}div.widget_uil_autotemp.evo_withexcerpt.evo_1pic__special ul li div.item_content p,div.widget_uil_autotemp.evo_withexcerpt.evo_1pic__special ul li div.item_excerpt p,div.widget_uil_autotemp.evo_withteaser.evo_1pic__special ul li div.item_content p,div.widget_uil_autotemp.evo_withteaser.evo_1pic__special ul li div.item_excerpt p{margin:0}div.widget_uil_autotemp.evo_withexcerpt.evo_1pic__special ul li div.item_content p:last-of-type,div.widget_uil_autotemp.evo_withexcerpt.evo_1pic__special ul li div.item_excerpt p:last-of-type,div.widget_uil_autotemp.evo_withteaser.evo_1pic__special ul li div.item_content p:last-of-type,div.widget_uil_autotemp.evo_withteaser.evo_1pic__special ul li div.item_excerpt p:last-of-type{display:inline}div.widget_uil_autotemp.evo_withexcerpt ul li,div.widget_uil_autotemp.evo_withteaser ul li{height:auto;width:100%;clear:both;margin:15px 0;padding:0;vertical-align:middle}div.widget_uil_autotemp.evo_withexcerpt ul li div.item_title,div.widget_uil_autotemp.evo_withteaser ul li div.item_title{vertical-align:middle;display:inline;height:auto!important;width:100%;font-size:16px}div.widget_uil_autotemp.evo_withexcerpt ul li div.item_title a,div.widget_uil_autotemp.evo_withteaser ul li div.item_title a{text-decoration:underline}div.widget_uil_autotemp.evo_withexcerpt blockquote,div.widget_uil_autotemp.evo_withteaser blockquote{display:block;margin:0;padding:5px 15px}div.widget_uil_autotemp.evo_withexcerpt a.btn,div.widget_uil_autotemp.evo_withteaser a.btn{background-color:transparent;float:right;height:22px;line-height:13px;padding:0 4px 0 4px}div.widget_uil_autotemp.evo_withexcerpt a.btn:hover,div.widget_uil_autotemp.evo_withteaser a.btn:hover{background-color:#e6e6e6}div.widget_uil_autotemp img{border-radius:3px;max-width:100%;max-height:380px;width:auto;height:auto;margin:auto}div.widget_uil_autotemp.evo_withgroup>ul>li{font-size:17px}div.widget_uil_autotemp div.item_first_image{text-align:center}div.evo_container__sidebar div.widget_uil_autotemp.evo_1pic__special.evo_noexcerpt.evo_noteaser div.item_title a,div.evo_container__sidebar_2 div.widget_uil_autotemp.evo_1pic__special.evo_noexcerpt.evo_noteaser div.item_title a{font-size:16px}div.widget_uil_autotemp.nobullets ul,div.widget_uil_autotemp.nobullets ul li,li.widget_uil_autotemp.nobullets ul,li.widget_uil_autotemp.nobullets ul li{background:0 0;margin-left:0;padding-left:0;list-style:none}div.widget_uil_autotemp.nobullets ul li:before,ul li.widget_uil_autotemp.nobullets ul li:before{content:none}@media (max-width:1599px){div.widget_uil_autotemp.evo_1pic__special.evo_noexcerpt.evo_noteaser div.item_title a{font-size:20px}}@media (max-width:1199px){div.widget_uil_autotemp.evo_1pic__special.evo_noexcerpt.evo_noteaser div.item_title a{font-size:18px}}@media (max-width:414px){div.widget_uil_autotemp.evo_1pic__special ul li .item_first_image_placeholder{max-width:290px;max-height:290px}}div.widget_core_coll_media_index.evo_layout_list ul li img{margin:0 6px 6px 0}div.widget_core_coll_media_index.evo_layout_flow .widget_flow_blocks>div,div.widget_core_coll_media_index.evo_layout_rwd .widget_rwd_blocks>div{display:inline-block;float:none;vertical-align:top}div.widget_core_coll_media_index.evo_layout_flow .widget_flow_blocks>div,div.widget_core_coll_media_index.evo_layout_rwd .widget_rwd_blocks .widget_rwd_content{padding:8px;margin:14px 0;overflow:hidden;background-color:#fafafa;border-radius:4px}div.widget_core_coll_media_index.evo_layout_flow .widget_flow_blocks>div img,div.widget_core_coll_media_index.evo_layout_rwd .widget_rwd_blocks .widget_rwd_content img{max-width:100%;max-height:380px;width:auto;height:auto;margin:auto;min-height:32px;min-width:32px;display:block;border-radius:3px}div.widget_core_coll_media_index.evo_layout_flow .widget_flow_blocks>div span.note,div.widget_core_coll_media_index.evo_layout_rwd .widget_rwd_blocks .widget_rwd_content span.note{margin-top:8px;display:block}div.widget_core_coll_media_index.evo_layout_flow .widget_flow_blocks{display:inline-block;text-align:center;width:100%}div.widget_core_coll_media_index.evo_layout_flow .widget_flow_blocks>div{margin-left:14px;margin-right:14px;text-align:left;width:250px}div.widget_core_user_avatars.evo_layout_flow .widget_flow_blocks>div,div.widget_core_user_avatars.evo_layout_rwd .widget_rwd_blocks .widget_rwd_content{padding:8px;margin:14px 0;overflow:hidden;background-color:#fafafa;border-radius:4px}div.widget_core_user_avatars.evo_layout_flow .widget_flow_blocks{display:inline-block;text-align:center}div.widget_core_user_avatars.evo_layout_flow .widget_flow_blocks>div{margin-left:14px;margin-right:14px;width:250px}div.widget_core_user_avatars.evo_layout_flow .widget_flow_blocks>div,div.widget_core_user_avatars.evo_layout_rwd .widget_rwd_blocks>div{display:inline-block;vertical-align:top}div.widget_core_user_avatars.evo_layout_flow .widget_flow_blocks>div img,div.widget_core_user_avatars.evo_layout_rwd .widget_rwd_blocks .widget_rwd_content img{max-width:100%;max-height:380px;width:auto;height:auto;margin:auto;display:block;border-radius:3px}.widget_core_item_about_author .evo_avatar{float:left;margin:0 10px 5px 0}.widget_core_item_about_author .evo_avatar img{border-radius:50%}.widget_core_org_members{margin:5em 0 30px;color:#333}.widget_core_org_members div.widget_rwd_content{text-align:center;margin-top:20px;margin-bottom:30px}.widget_core_org_members.evo_layout_flow .widget_flow_blocks{display:inline-block;text-align:center}.widget_core_org_members.evo_layout_flow .widget_flow_blocks>div{display:inline-block;float:none;margin-left:14px;margin-right:14px;vertical-align:top;width:250px}.widget_core_org_members.evo_layout_flow .widget_flow_blocks>div img{border-radius:50%}.widget_core_org_members img{display:inline-block}.widget_core_org_members h3.evo_user_name{margin-top:10px;margin-bottom:0}.widget_core_org_members div.evo_org_role{margin-top:10px;margin-bottom:0;min-height:25px;font-size:18px}.widget_core_org_members a.user_link{color:#000}.widget_core_org_members a.user_link:hover{color:#23527c}.widget_core_org_members div.ufld_icon_links{margin-top:10px;min-height:44px}.widget_core_org_members p.user_field{margin-top:10px;line-height:1.5;text-overflow:ellipsis;display:-webkit-box;-webkit-box-orient:vertical;overflow:hidden;-webkit-line-clamp:2;height:3em}.widget_core_org_members .widget_rwd_blocks{width:100%}.widget_core_org_members.evo_layout_list ul li div.ufld_icon_links{text-align:left}@media (max-width:640px){body.pictured .front_main_content .ufld_icon_links a{width:45px;height:45px;margin:5px}body.pictured .front_main_content .ufld_icon_links a .fa{font-size:20px;line-height:45px}}.evo_container__header{margin-bottom:20px}.evo_container__page_top{margin-top:20px}.evo_container__page_top .ufld_icon_links{text-align:right}.nav.nav-tabs{margin-top:0}ul.profile_tabs{margin:0 2ex 2ex;position:relative;top:1px}.profile_avatar{float:right;padding:10px;margin-left:10px}.form-horizontal .controls textarea.form-control{width:100%}input.search_field{margin-bottom:0;display:inline-block}form.search .search_options{width:100%}form.search .search_options .search_option input{margin-right:5px}form.search .search_options .search_option label{margin-bottom:0;margin-top:5px}div.compact_search_form input.search_field{width:100%;margin:0}div.extended_search_form{text-align:center;margin:0 auto 2em auto;max-width:530px}div.extended_search_form .search_options{text-align:center}div.extended_search_form .search_options .search_option{display:inline-block;margin-right:10px}textarea.message_text{width:95%}.evo_comment_title a,.pull-right .evo_comment_type{color:#337ab7}.evo_post{margin-bottom:2em}.evo_post .small.text-muted{margin:4px 0 10px}.evo_post .small.text-muted a,.evo_post .small.text-muted a .glyphicon{color:inherit}.evo_comment_avatar img{float:left;border-radius:50%;margin:0 10px 10px 0}div.bSideItem{background:#f7f5fa;border-radius:5px;padding:10px;margin-bottom:10px;text-shadow:0 1px 0 #fff}div.bSideItem h4{margin-top:0}.skin-form .panel-body .panel{border:none;box-shadow:none}.skin-form .panel-body .panel-body{padding:0}.skin-form .fieldset{margin:0}.skin-form .fieldset div.input{margin:0}.skin-form .control-buttons,.skin-form div.input{padding:0;width:100%;text-align:center}.evo_panel__activation,.evo_panel__login,.evo_panel__lostpass,.evo_panel__register{min-width:290px;margin:1.5em auto auto}.evo_panel__activation .panel,.evo_panel__login .panel,.evo_panel__lostpass .panel,.evo_panel__register .panel{margin:5px 0}.evo_panel__activation .panel-body,.evo_panel__login .panel-body,.evo_panel__lostpass .panel-body,.evo_panel__register .panel-body{padding-top:20px;padding-bottom:0}.evo_panel__login{max-width:400px;min-width:auto}.evo_panel__lostpass{max-width:480px}.evo_panel__lostpass #ffield_x label{display:none}.evo_panel__activation{max-width:530px}.evo_panel__activation #activateinfo_form .control-buttons{text-align:left}.evo_panel__register{max-width:580px}.evo_panel__register .form-control#country,.evo_panel__register .form-control#u{width:100%}.evo_panel__register #fieldset_wrapper_captcha_qstn .panel{margin:0}.evo_panel__register #fieldset_wrapper_captcha_qstn .panel div[id$=_answer] .control-label{padding-right:14px}.evo_panel__register .panel-body{padding:15px}.evo_panel__register .panel-body p:last-child{margin-bottom:0}@media (min-width:768px){#fieldset_wrapper_captcha_qstn .panel div[id$=_answer]{max-height:34px}}.evo_register_buttons{text-align:center}.evo_register_buttons input.btn{margin:0 0 15px 0}.evo_register_buttons a.btn{margin:0}.evo_form__login_links{padding:0 5px;font-size:92%}.evo_form__login fieldset{margin-bottom:20px}.evo_form__login .controls{padding:0;margin:0;width:100%}.evo_form__login .control-buttons{margin-left:0}.evo_form__login input.form-control[type=password],.evo_form__login input.form-control[type=text]{width:100%}.evo_form__login .btn{margin-top:5px}#login_form .control-buttons{text-align:left}.standard_login_link{text-align:center;margin:3em 0 1ex 0}.form_footer_notes{margin-top:0}.post_tags{margin:10px 0}.pagination{margin:0}div.action_messages,div.log_container{margin:0}.evo_post .well{padding:15px}.evo_post .well .evo_post_title{display:table}.evo_post .well .evo_post_title h1{margin-top:0}.evo_post .well .evo_post_title h2,.evo_post .well .evo_post_title h3{display:table-cell;margin:0;padding:0 0 10px}.evo_post .well .evo_post_title h2+.btn,.evo_post .well .evo_post_title h3+.btn{margin:-10px 0 0 30px}.evo_post .well .evo_post_title .btn-group{display:table-cell;padding:20px 0 10px 30px;vertical-align:middle}.evo_post .well .evo_post_title .evo_post_read_status{display:table-cell;vertical-align:middle;padding:0 2px 10px 0}.featurepost .evo_post_title h2,.well .evo_post_title h2{display:table-cell;padding:20px 0 10px}.featurepost .evo_post_title .btn-group,.well .evo_post_title .btn-group{display:table-cell;padding:20px 0 10px 30px;vertical-align:middle}.well.evo_featured_post .well{background-color:transparent!important;border:0!important;border-radius:0!important;box-shadow:none!important;padding:0}footer.row{margin-top:20px}.evo_content_block .evo_comment .evo_comment_footer .action_btn_group{float:right}.evo_content_block .evo_comment .comment_edit_btn{margin-right:5px}.evo_content_block .evo_comment .btn-group>.btn.first-child{border-top-left-radius:3px!important;border-bottom-left-radius:3px!important} \ No newline at end of file +div.widget_uil_autotemp.evo_layout_flow .widget_flow_blocks{display:inline-block;text-align:center;width:100%}div.widget_uil_autotemp.evo_layout_flow .widget_flow_blocks>div{padding:8px;margin:14px;overflow:hidden;background-color:#fafafa;border-radius:4px;text-align:left;width:250px;display:inline-block;float:none;vertical-align:top}div.widget_uil_autotemp.evo_layout_flow.evo_withexcerpt .widget_flow_blocks>div .item_title,div.widget_uil_autotemp.evo_layout_flow.evo_withteaser .widget_flow_blocks>div .item_title{font-size:16px;font-weight:700;line-height:1.5em;margin:10px 0 5px}div.widget_uil_autotemp.evo_layout_rwd .widget_rwd_content{padding:8px;margin:14px 0;overflow:hidden;background-color:#fafafa;border-radius:4px}div.widget_uil_autotemp.evo_layout_rwd.evo_withexcerpt .widget_rwd_blocks>div,div.widget_uil_autotemp.evo_layout_rwd.evo_withteaser .widget_rwd_blocks>div{display:inline-block;float:none;vertical-align:top}div.widget_uil_autotemp.evo_layout_rwd.evo_withexcerpt .widget_rwd_blocks .widget_rwd_content .item_first_image img,div.widget_uil_autotemp.evo_layout_rwd.evo_withteaser .widget_rwd_blocks .widget_rwd_content .item_first_image img{width:100%;height:240px;object-fit:cover;margin:auto}div.widget_uil_autotemp.evo_layout_rwd.evo_withexcerpt .widget_rwd_blocks .widget_rwd_content .item_title,div.widget_uil_autotemp.evo_layout_rwd.evo_withteaser .widget_rwd_blocks .widget_rwd_content .item_title{font-size:16px;font-weight:700;line-height:1.5em;margin:10px 0 5px}div.widget_uil_autotemp.evo_layout_rwd.evo_withexcerpt .widget_rwd_blocks .widget_rwd_content .item_content>p:last-of-type,div.widget_uil_autotemp.evo_layout_rwd.evo_withteaser .widget_rwd_blocks .widget_rwd_content .item_content>p:last-of-type{min-height:60px;margin-bottom:0}div.widget_uil_autotemp.evo_layout_rwd.evo_withexcerpt .widget_rwd_blocks .widget_rwd_content .item_content a,div.widget_uil_autotemp.evo_layout_rwd.evo_withteaser .widget_rwd_blocks .widget_rwd_content .item_content a{margin:-20px 0 0}div.widget_uil_autotemp.evo_1pic__special h2{font-size:30px}div.widget_uil_autotemp.evo_1pic__special ul{padding:0;margin-left:0}div.widget_uil_autotemp.evo_1pic__special ul li{list-style:none;height:auto;display:inline-block;width:100%;clear:both;margin:5px 0;padding:0;vertical-align:middle}div.widget_uil_autotemp.evo_1pic__special ul li .item_first_image_placeholder{display:table;float:left;max-width:380px;max-height:380px;background:#f0f0f0;margin-right:6px;border-radius:3px}div.widget_uil_autotemp.evo_1pic__special ul li .item_first_image_placeholder::before{font-family:FontAwesome;display:table-cell;content:'\f0f6';color:#dcdcdc;font-size:40px;vertical-align:middle;text-align:center}div.widget_uil_autotemp.evo_1pic__special ul li div.item_title{vertical-align:middle;height:80px;display:-webkit-box;display:table-cell;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;text-overflow:ellipsis}div.widget_uil_autotemp.evo_1pic__special.evo_noexcerpt.evo_noteaser div.item_title a{font-size:22px}div.widget_uil_autotemp.evo_layout_list div.item_first_image{float:left;margin-right:6px}div.widget_uil_autotemp.evo_pics div.item_images{display:inline-block}div.widget_uil_autotemp.evo_pics div.item_images img{margin:6px 6px 0 0}div.widget_uil_autotemp.evo_pics.evo_1pic__special li{display:block;width:100%}div.widget_uil_autotemp.evo_pics.evo_1pic__special div.item_images{float:left}div.widget_uil_autotemp.evo_withexcerpt.evo_1pic__special ul li,div.widget_uil_autotemp.evo_withteaser.evo_1pic__special ul li{list-style:none;display:table}div.widget_uil_autotemp.evo_withexcerpt.evo_1pic__special ul li div.item_title a,div.widget_uil_autotemp.evo_withteaser.evo_1pic__special ul li div.item_title a{text-decoration:underline}div.widget_uil_autotemp.evo_withexcerpt.evo_1pic__special ul li div.item_content blockquote,div.widget_uil_autotemp.evo_withteaser.evo_1pic__special ul li div.item_content blockquote{margin-left:86px}div.widget_uil_autotemp.evo_withexcerpt.evo_1pic__special ul li div.item_excerpt,div.widget_uil_autotemp.evo_withteaser.evo_1pic__special ul li div.item_excerpt{margin-top:-2px}div.widget_uil_autotemp.evo_withexcerpt.evo_1pic__special ul li div.item_content p,div.widget_uil_autotemp.evo_withexcerpt.evo_1pic__special ul li div.item_excerpt p,div.widget_uil_autotemp.evo_withteaser.evo_1pic__special ul li div.item_content p,div.widget_uil_autotemp.evo_withteaser.evo_1pic__special ul li div.item_excerpt p{margin:0}div.widget_uil_autotemp.evo_withexcerpt.evo_1pic__special ul li div.item_content p:last-of-type,div.widget_uil_autotemp.evo_withexcerpt.evo_1pic__special ul li div.item_excerpt p:last-of-type,div.widget_uil_autotemp.evo_withteaser.evo_1pic__special ul li div.item_content p:last-of-type,div.widget_uil_autotemp.evo_withteaser.evo_1pic__special ul li div.item_excerpt p:last-of-type{display:inline}div.widget_uil_autotemp.evo_withexcerpt ul li,div.widget_uil_autotemp.evo_withteaser ul li{height:auto;width:100%;clear:both;margin:15px 0;padding:0;vertical-align:middle}div.widget_uil_autotemp.evo_withexcerpt ul li div.item_title,div.widget_uil_autotemp.evo_withteaser ul li div.item_title{vertical-align:middle;display:inline;height:auto!important;width:100%;font-size:16px}div.widget_uil_autotemp.evo_withexcerpt ul li div.item_title a,div.widget_uil_autotemp.evo_withteaser ul li div.item_title a{text-decoration:underline}div.widget_uil_autotemp.evo_withexcerpt blockquote,div.widget_uil_autotemp.evo_withteaser blockquote{display:block;margin:0;padding:5px 15px}div.widget_uil_autotemp.evo_withexcerpt a.btn,div.widget_uil_autotemp.evo_withteaser a.btn{background-color:transparent;float:right;height:22px;line-height:13px;padding:0 4px 0 4px}div.widget_uil_autotemp.evo_withexcerpt a.btn:hover,div.widget_uil_autotemp.evo_withteaser a.btn:hover{background-color:#e6e6e6}div.widget_uil_autotemp img{border-radius:3px;max-width:100%;max-height:380px;width:auto;height:auto;margin:auto}div.widget_uil_autotemp.evo_withgroup>ul>li{font-size:17px}div.widget_uil_autotemp div.item_first_image{text-align:center}div.evo_container__sidebar div.widget_uil_autotemp.evo_1pic__special.evo_noexcerpt.evo_noteaser div.item_title a,div.evo_container__sidebar_2 div.widget_uil_autotemp.evo_1pic__special.evo_noexcerpt.evo_noteaser div.item_title a{font-size:16px}div.widget_uil_autotemp.nobullets ul,div.widget_uil_autotemp.nobullets ul li,li.widget_uil_autotemp.nobullets ul,li.widget_uil_autotemp.nobullets ul li{background:0 0;margin-left:0;padding-left:0;list-style:none}div.widget_uil_autotemp.nobullets ul li:before,ul li.widget_uil_autotemp.nobullets ul li:before{content:none}@media (max-width:1599px){div.widget_uil_autotemp.evo_1pic__special.evo_noexcerpt.evo_noteaser div.item_title a{font-size:20px}}@media (max-width:1199px){div.widget_uil_autotemp.evo_1pic__special.evo_noexcerpt.evo_noteaser div.item_title a{font-size:18px}}@media (max-width:414px){div.widget_uil_autotemp.evo_1pic__special ul li .item_first_image_placeholder{max-width:290px;max-height:290px}}div.widget_core_coll_media_index.evo_layout_list ul li img{margin:0 6px 6px 0}div.widget_core_coll_media_index.evo_layout_flow .widget_flow_blocks>div,div.widget_core_coll_media_index.evo_layout_rwd .widget_rwd_blocks>div{display:inline-block;float:none;vertical-align:top}div.widget_core_coll_media_index.evo_layout_flow .widget_flow_blocks>div,div.widget_core_coll_media_index.evo_layout_rwd .widget_rwd_blocks .widget_rwd_content{padding:8px;margin:14px 0;overflow:hidden;background-color:#fafafa;border-radius:4px}div.widget_core_coll_media_index.evo_layout_flow .widget_flow_blocks>div img,div.widget_core_coll_media_index.evo_layout_rwd .widget_rwd_blocks .widget_rwd_content img{max-width:100%;max-height:380px;width:auto;height:auto;margin:auto;min-height:32px;min-width:32px;display:block;border-radius:3px}div.widget_core_coll_media_index.evo_layout_flow .widget_flow_blocks>div span.note,div.widget_core_coll_media_index.evo_layout_rwd .widget_rwd_blocks .widget_rwd_content span.note{margin-top:8px;display:block}div.widget_core_coll_media_index.evo_layout_flow .widget_flow_blocks{display:inline-block;text-align:center;width:100%}div.widget_core_coll_media_index.evo_layout_flow .widget_flow_blocks>div{margin-left:14px;margin-right:14px;text-align:left;width:250px}div.widget_core_user_avatars.evo_layout_flow .widget_flow_blocks>div,div.widget_core_user_avatars.evo_layout_rwd .widget_rwd_blocks .widget_rwd_content{padding:8px;margin:14px 0;overflow:hidden;background-color:#fafafa;border-radius:4px}div.widget_core_user_avatars.evo_layout_flow .widget_flow_blocks{display:inline-block;text-align:center}div.widget_core_user_avatars.evo_layout_flow .widget_flow_blocks>div{margin-left:14px;margin-right:14px;width:250px}div.widget_core_user_avatars.evo_layout_flow .widget_flow_blocks>div,div.widget_core_user_avatars.evo_layout_rwd .widget_rwd_blocks>div{display:inline-block;vertical-align:top}div.widget_core_user_avatars.evo_layout_flow .widget_flow_blocks>div img,div.widget_core_user_avatars.evo_layout_rwd .widget_rwd_blocks .widget_rwd_content img{max-width:100%;max-height:380px;width:auto;height:auto;margin:auto;display:block;border-radius:3px}.widget_core_item_about_author .evo_avatar{float:left;margin:0 10px 5px 0}.widget_core_item_about_author .evo_avatar img{border-radius:50%}.widget_core_org_members{margin:5em 0 30px;color:#333}.widget_core_org_members div.widget_rwd_content{text-align:center;margin-top:20px;margin-bottom:30px}.widget_core_org_members.evo_layout_flow .widget_flow_blocks{display:inline-block;text-align:center}.widget_core_org_members.evo_layout_flow .widget_flow_blocks>div{display:inline-block;float:none;margin-left:14px;margin-right:14px;vertical-align:top;width:250px}.widget_core_org_members.evo_layout_flow .widget_flow_blocks>div img{border-radius:50%}.widget_core_org_members img{display:inline-block}.widget_core_org_members h3.evo_user_name{margin-top:10px;margin-bottom:0}.widget_core_org_members div.evo_org_role{margin-top:10px;margin-bottom:0;min-height:25px;font-size:18px}.widget_core_org_members a.user_link{color:#000}.widget_core_org_members a.user_link:hover{color:#23527c}.widget_core_org_members div.ufld_icon_links{margin-top:10px;min-height:44px}.widget_core_org_members p.user_field{margin-top:10px;line-height:1.5;text-overflow:ellipsis;display:-webkit-box;-webkit-box-orient:vertical;overflow:hidden;-webkit-line-clamp:2;height:3em}.widget_core_org_members .widget_rwd_blocks{width:100%}.widget_core_org_members.evo_layout_list ul li div.ufld_icon_links{text-align:left}@media (max-width:640px){body.pictured .front_main_content .ufld_icon_links a{width:45px;height:45px;margin:5px}body.pictured .front_main_content .ufld_icon_links a .fa{font-size:20px;line-height:45px}}.evo_container__header{margin-bottom:20px}.evo_container__page_top{margin-top:20px}.evo_container__page_top .ufld_icon_links{text-align:right}.nav.nav-tabs{margin-top:0}ul.profile_tabs{margin:0 2ex 2ex;position:relative;top:1px}.profile_avatar{float:right;padding:10px;margin-left:10px}.form-horizontal .controls textarea.form-control{width:100%}input.search_field{margin-bottom:0;display:inline-block}form.search .search_options{width:100%}form.search .search_options .search_option input{margin-right:5px}form.search .search_options .search_option label{margin-bottom:0;margin-top:5px}div.compact_search_form input.search_field{width:100%;margin:0}div.extended_search_form{text-align:center;margin:0 auto 2em auto;max-width:530px}div.extended_search_form .search_options{text-align:center}div.extended_search_form .search_options .search_option{display:inline-block;margin-right:10px}textarea.message_text{width:95%}.evo_comment_title a,.pull-right .evo_comment_type{color:#337ab7}.evo_post{margin-bottom:2em}.evo_post .small.text-muted{margin:4px 0 10px}.evo_post .small.text-muted a,.evo_post .small.text-muted a .glyphicon{color:inherit}.evo_comment_avatar img{float:left;border-radius:50%;margin:0 10px 10px 0}div.bSideItem{background:#f7f5fa;border-radius:5px;padding:10px;margin-bottom:10px;text-shadow:0 1px 0 #fff}div.bSideItem h4{margin-top:0}.skin-form .panel-body .panel{border:none;box-shadow:none}.skin-form .panel-body .panel-body{padding:0}.skin-form .fieldset{margin:0}.skin-form .fieldset div.input{margin:0}.skin-form .control-buttons,.skin-form div.input{padding:0;width:100%;text-align:center}.evo_panel__activation,.evo_panel__login,.evo_panel__lostpass,.evo_panel__register{min-width:290px;margin:1.5em auto auto}.evo_panel__activation .panel,.evo_panel__login .panel,.evo_panel__lostpass .panel,.evo_panel__register .panel{margin:5px 0}.evo_panel__activation .panel-body,.evo_panel__login .panel-body,.evo_panel__lostpass .panel-body,.evo_panel__register .panel-body{padding-top:20px;padding-bottom:0}.evo_panel__login{max-width:400px;min-width:auto}.evo_panel__lostpass{max-width:480px}.evo_panel__lostpass #ffield_x label{display:none}.evo_panel__activation{max-width:530px}.evo_panel__activation #activateinfo_form .control-buttons{text-align:left}.evo_panel__register{max-width:580px}.evo_panel__register .form-control#country,.evo_panel__register .form-control#u{width:100%}.evo_panel__register #fieldset_wrapper_captcha_qstn .panel{margin:0}.evo_panel__register #fieldset_wrapper_captcha_qstn .panel div[id$=_answer] .control-label{padding-right:14px}.evo_panel__register .panel-body{padding:15px}.evo_panel__register .panel-body p:last-child{margin-bottom:0}@media (min-width:768px){#fieldset_wrapper_captcha_qstn .panel div[id$=_answer]{max-height:34px}}.evo_register_buttons{text-align:center}.evo_register_buttons input.btn{margin:0 0 15px 0}.evo_register_buttons a.btn{margin:0}.evo_form__login_links{padding:0 5px;font-size:92%}.evo_form__login fieldset{margin-bottom:20px}.evo_form__login .controls{padding:0;margin:0;width:100%}.evo_form__login .control-buttons{margin-left:0}.evo_form__login input.form-control[type=password],.evo_form__login input.form-control[type=text]{width:100%}.evo_form__login .btn{margin-top:5px}#login_form .control-buttons{text-align:left}.standard_login_link{text-align:center;margin:3em 0 1ex 0}.form_footer_notes{margin-top:0}.post_tags{margin:10px 0}.pagination{margin:0}div.action_messages,div.log_container{margin:0}.evo_post .well{padding:15px}.evo_post .well .evo_post_title{display:table}.evo_post .well .evo_post_title h1{margin-top:0}.evo_post .well .evo_post_title h2,.evo_post .well .evo_post_title h3{display:table-cell;margin:0;padding:0 0 10px}.evo_post .well .evo_post_title h2+.btn,.evo_post .well .evo_post_title h3+.btn{margin:-10px 0 0 30px}.evo_post .well .evo_post_title .btn-group{display:table-cell;padding:20px 0 10px 30px;vertical-align:middle}.evo_post .well .evo_post_title .evo_post_read_status{display:table-cell;vertical-align:middle;padding:0 2px 10px 0}.featurepost .evo_post_title h2,.well .evo_post_title h2{display:table-cell;padding:20px 0 10px}.featurepost .evo_post_title .btn-group,.well .evo_post_title .btn-group{display:table-cell;padding:20px 0 10px 30px;vertical-align:middle}.well.evo_featured_post .well{background-color:transparent!important;border:0!important;border-radius:0!important;box-shadow:none!important;padding:0}footer.row{margin-top:20px}.evo_content_block .evo_comment .evo_comment_footer .action_btn_group{float:right}.evo_content_block .evo_comment .comment_edit_btn{margin-right:5px}.evo_content_block .evo_comment .btn-group>.btn.first-child{border-top-left-radius:3px!important;border-bottom-left-radius:3px!important} \ No newline at end of file diff --git a/skins/bootstrap_site_dropdown_skin/_html_footer.inc.php b/skins/bootstrap_site_dropdown_skin/_html_footer.inc.php index cd14d699613..ea3792c2451 100644 --- a/skins/bootstrap_site_dropdown_skin/_html_footer.inc.php +++ b/skins/bootstrap_site_dropdown_skin/_html_footer.inc.php @@ -12,6 +12,6 @@ - + - \ No newline at end of file + diff --git a/skins/bootstrap_site_dropdown_skin/_site_body_header.inc.php b/skins/bootstrap_site_dropdown_skin/_site_body_header.inc.php index 3df6a3689ee..31905c740c5 100644 --- a/skins/bootstrap_site_dropdown_skin/_site_body_header.inc.php +++ b/skins/bootstrap_site_dropdown_skin/_site_body_header.inc.php @@ -10,7 +10,7 @@ */ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); -global $baseurl, $Settings, $Blog, $disp, $current_User, $site_Skin; +global $baseurl, $Settings, $Blog, $disp, $site_Skin; $notification_logo_file_ID = intval( $Settings->get( 'notification_logo_file_ID' ) ); if( $notification_logo_file_ID > 0 && @@ -52,8 +52,7 @@ { // Display the grouped header tabs: foreach( $header_tabs as $s => $header_tab ) { // Display level 0 tabs: - // Current collection gets class "active" - echo 'header_tab_active === $s || ! empty( $header_tab['active'] ) ? ' class="active"' : '' ) . '>'; + echo 'get_header_tab_attr_class( $header_tab, $s ).'>'; // If collections grouped in a section exist and have at least one collection: if( isset( $header_tab['items'] ) && @@ -76,7 +75,7 @@ if( is_array( $menu_item ) ) { // Display sub menus: ?> - > + get_header_tab_attr_class( $menu_item ); ?>> > '', 'item_selected_start' => '', 'item_selected_end' => '', - 'profile_menu_link_text' => 'avatar_force_login', + 'link_text_myprofile' => '$login$', ) ); // ----------------------------- END OF "Right Navigation" CONTAINER ----------------------------- ?> @@ -214,33 +213,7 @@ { // Check if "Back to Top" button is enabled ?> - - - \ No newline at end of file + diff --git a/skins/bootstrap_site_dropdown_skin/_skin.class.php b/skins/bootstrap_site_dropdown_skin/_skin.class.php index 3b54366623f..f15689d96c7 100644 --- a/skins/bootstrap_site_dropdown_skin/_skin.class.php +++ b/skins/bootstrap_site_dropdown_skin/_skin.class.php @@ -23,7 +23,7 @@ class bootstrap_site_dropdown_Skin extends site_Skin * Skin version * @var string */ - var $version = '7.1.7'; + var $version = '7.2.5'; /** * Do we want to use style.min.css instead of style.css ? diff --git a/skins/bootstrap_site_dropdown_skin/style.css b/skins/bootstrap_site_dropdown_skin/style.css index e6bd9c07a44..86c9ccf784c 100644 --- a/skins/bootstrap_site_dropdown_skin/style.css +++ b/skins/bootstrap_site_dropdown_skin/style.css @@ -21,12 +21,12 @@ border-top: 1px solid; padding-top: 9px; } -#evo_site_header .navbar .navbar-collapse .nav .login { +#evo_site_header .navbar .navbar-collapse .nav .evo_widget_basic_menu_link_myprofile { padding-top: 4px; padding-bottom: 4px; line-height: 32px; } -#evo_site_header .navbar .navbar-collapse .nav .login img { +#evo_site_header .navbar .navbar-collapse .nav .evo_widget_basic_menu_link_myprofile img { margin-right: 5px; border-radius: 4px; } @@ -58,7 +58,7 @@ #evo_site_header .navbar .navbar-collapse .nav.navbar-right li.evo_widget > a { display: inline-block; } - #evo_site_header .navbar .navbar-collapse .nav.navbar-right .login { + #evo_site_header .navbar .navbar-collapse .nav.navbar-right .evo_widget_basic_menu_link_myprofile { padding-top: 8px; padding-bottom: 9px; } diff --git a/skins/bootstrap_site_dropdown_skin/style.less b/skins/bootstrap_site_dropdown_skin/style.less index f6bc903255a..557593f5e52 100644 --- a/skins/bootstrap_site_dropdown_skin/style.less +++ b/skins/bootstrap_site_dropdown_skin/style.less @@ -24,7 +24,7 @@ padding-top: 9px; // Visual adaptation to the border-top } - .login { + .evo_widget_basic_menu_link_myprofile { padding-top: 4px; padding-bottom: 4px; line-height: 32px; @@ -80,7 +80,7 @@ li.evo_widget > a { display: inline-block; } - .login { + .evo_widget_basic_menu_link_myprofile { padding-top: 8px; padding-bottom: 9px; } diff --git a/skins/bootstrap_site_dropdown_skin/style.min.css b/skins/bootstrap_site_dropdown_skin/style.min.css index ae9aa1adf78..df1d9083921 100644 --- a/skins/bootstrap_site_dropdown_skin/style.min.css +++ b/skins/bootstrap_site_dropdown_skin/style.min.css @@ -1 +1 @@ -#evo_site_header .navbar{margin-bottom:0}#evo_site_header .navbar .navbar-header.navbar-header-with-logo .navbar-brand{padding:0}#evo_site_header .navbar .navbar-header.navbar-header-with-logo .navbar-brand img{max-height:100%;max-width:270px}#evo_site_header .navbar .navbar-collapse{padding:0}#evo_site_header .navbar .navbar-collapse .nav{margin:0}#evo_site_header .navbar .navbar-collapse .nav.navbar-right{border-top:1px solid;padding-top:9px}#evo_site_header .navbar .navbar-collapse .nav .login{padding-top:4px;padding-bottom:4px;line-height:32px}#evo_site_header .navbar .navbar-collapse .nav .login img{margin-right:5px;border-radius:4px}#evo_site_header .navbar .navbar-collapse .nav li .dropdown-menu{border-radius:0;padding:0}#evo_site_header .navbar .navbar-collapse .nav li .dropdown-menu li a{padding:10px 20px;color:#555}#evo_site_header .level2 ul.nav.nav-pills{margin:15px 0}@media (min-width:768px){#evo_site_header .navbar .container-fluid.level1{padding-right:0}#evo_site_header .navbar .navbar-header.navbar-header-with-logo .navbar-brand{margin-left:-15px}#evo_site_header .navbar .navbar-collapse .nav.navbar-left{margin-right:15px}#evo_site_header .navbar .navbar-collapse .nav.navbar-right{border-top:none;padding:0}#evo_site_header .navbar .navbar-collapse .nav.navbar-right li.evo_widget>a{display:inline-block}#evo_site_header .navbar .navbar-collapse .nav.navbar-right .login{padding-top:8px;padding-bottom:9px}}@media (max-width:768px){#evo_site_header .navbar .navbar-header.navbar-header-with-logo{margin-left:-15px}#evo_site_header .navbar .navbar-collapse .nav li .dropdown-menu{background-color:#f8f8f8}#evo_site_header .navbar .navbar-collapse .nav li .dropdown-menu li a{padding:10px 15px 10px 30px;width:100%}}#evo_site_footer{background-color:#f5f5f5}#evo_site_footer p{margin:20px 0}.btn.slide-top{opacity:0;visibility:hidden;float:right;font-size:20px;position:fixed;padding:2px 13px;right:8px;top:8px;transition:all .3s;z-index:9999}.btn.slide-top.slide-top-visible{opacity:1;visibility:visible}.btn.slide-top.slide-top-toolbar{top:35px}.btn.slide-top.slide-top-fixed-header{top:50px}.btn.slide-top.slide-top-toolbar.slide-top-fixed-header{top:85px}@media only screen and (max-device-width:1024px){.btn.slide-top.slide-top-toolbar{top:8px}}@media (min-width:768px) and (max-width:991px) and (min-device-width:1024px){.btn.slide-top.slide-top-toolbar{top:35px}} \ No newline at end of file +#evo_site_header .navbar{margin-bottom:0}#evo_site_header .navbar .navbar-header.navbar-header-with-logo .navbar-brand{padding:0}#evo_site_header .navbar .navbar-header.navbar-header-with-logo .navbar-brand img{max-height:100%;max-width:270px}#evo_site_header .navbar .navbar-collapse{padding:0}#evo_site_header .navbar .navbar-collapse .nav{margin:0}#evo_site_header .navbar .navbar-collapse .nav.navbar-right{border-top:1px solid;padding-top:9px}#evo_site_header .navbar .navbar-collapse .nav .evo_widget_basic_menu_link_myprofile{padding-top:4px;padding-bottom:4px;line-height:32px}#evo_site_header .navbar .navbar-collapse .nav .evo_widget_basic_menu_link_myprofile img{margin-right:5px;border-radius:4px}#evo_site_header .navbar .navbar-collapse .nav li .dropdown-menu{border-radius:0;padding:0}#evo_site_header .navbar .navbar-collapse .nav li .dropdown-menu li a{padding:10px 20px;color:#555}#evo_site_header .level2 ul.nav.nav-pills{margin:15px 0}@media (min-width:768px){#evo_site_header .navbar .container-fluid.level1{padding-right:0}#evo_site_header .navbar .navbar-header.navbar-header-with-logo .navbar-brand{margin-left:-15px}#evo_site_header .navbar .navbar-collapse .nav.navbar-left{margin-right:15px}#evo_site_header .navbar .navbar-collapse .nav.navbar-right{border-top:none;padding:0}#evo_site_header .navbar .navbar-collapse .nav.navbar-right li.evo_widget>a{display:inline-block}#evo_site_header .navbar .navbar-collapse .nav.navbar-right .evo_widget_basic_menu_link_myprofile{padding-top:8px;padding-bottom:9px}}@media (max-width:768px){#evo_site_header .navbar .navbar-header.navbar-header-with-logo{margin-left:-15px}#evo_site_header .navbar .navbar-collapse .nav li .dropdown-menu{background-color:#f8f8f8}#evo_site_header .navbar .navbar-collapse .nav li .dropdown-menu li a{padding:10px 15px 10px 30px;width:100%}}#evo_site_footer{background-color:#f5f5f5}#evo_site_footer p{margin:20px 0}.btn.slide-top{opacity:0;visibility:hidden;float:right;font-size:20px;position:fixed;padding:2px 13px;right:8px;top:8px;transition:all .3s;z-index:9999}.btn.slide-top.slide-top-visible{opacity:1;visibility:visible}.btn.slide-top.slide-top-toolbar{top:35px}.btn.slide-top.slide-top-fixed-header{top:50px}.btn.slide-top.slide-top-toolbar.slide-top-fixed-header{top:85px}@media only screen and (max-device-width:1024px){.btn.slide-top.slide-top-toolbar{top:8px}}@media (min-width:768px) and (max-width:991px) and (min-device-width:1024px){.btn.slide-top.slide-top-toolbar{top:35px}} \ No newline at end of file diff --git a/skins/bootstrap_site_navbar_skin/_html_footer.inc.php b/skins/bootstrap_site_navbar_skin/_html_footer.inc.php index cd14d699613..b719a6e692d 100644 --- a/skins/bootstrap_site_navbar_skin/_html_footer.inc.php +++ b/skins/bootstrap_site_navbar_skin/_html_footer.inc.php @@ -12,6 +12,6 @@ - + - \ No newline at end of file + diff --git a/skins/bootstrap_site_navbar_skin/_site_body_header.inc.php b/skins/bootstrap_site_navbar_skin/_site_body_header.inc.php index 259f7a29db2..5d751b92e75 100644 --- a/skins/bootstrap_site_navbar_skin/_site_body_header.inc.php +++ b/skins/bootstrap_site_navbar_skin/_site_body_header.inc.php @@ -10,7 +10,7 @@ */ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); -global $baseurl, $Settings, $Blog, $disp, $current_User, $site_Skin; +global $baseurl, $Settings, $Blog, $disp, $site_Skin; $notification_logo_file_ID = intval( $Settings->get( 'notification_logo_file_ID' ) ); if( $notification_logo_file_ID > 0 && @@ -54,7 +54,7 @@ foreach( $header_tabs as $s => $header_tab ) { // Display level 0 tabs: ?> - header_tab_active === $s ? ' class="active"' : '' ); ?>> + get_header_tab_attr_class( $header_tab, $s ); ?>> > '', 'item_selected_start' => '', 'item_selected_end' => '', - 'profile_menu_link_text' => 'avatar_force_login', + 'link_text_myprofile' => '$login$', ) ); // ----------------------------- END OF "Right Navigation" CONTAINER ----------------------------- ?> @@ -171,7 +171,7 @@ if( is_array( $menu_item ) ) { // Display menu item for collection: ?> - > + get_header_tab_attr_class( $menu_item ); ?>> > - - - \ No newline at end of file + diff --git a/skins/bootstrap_site_navbar_skin/_skin.class.php b/skins/bootstrap_site_navbar_skin/_skin.class.php index fc987561fae..2d18d4e42a3 100644 --- a/skins/bootstrap_site_navbar_skin/_skin.class.php +++ b/skins/bootstrap_site_navbar_skin/_skin.class.php @@ -23,7 +23,7 @@ class bootstrap_site_navbar_Skin extends site_Skin * Skin version * @var string */ - var $version = '7.1.7'; + var $version = '7.2.5'; /** * Do we want to use style.min.css instead of style.css ? diff --git a/skins/bootstrap_site_navbar_skin/style.css b/skins/bootstrap_site_navbar_skin/style.css index 37501af6960..d677403a72b 100644 --- a/skins/bootstrap_site_navbar_skin/style.css +++ b/skins/bootstrap_site_navbar_skin/style.css @@ -21,12 +21,12 @@ border-top: 1px solid; padding-top: 9px; } -#evo_site_header .navbar .navbar-collapse .nav .login { +#evo_site_header .navbar .navbar-collapse .nav .evo_widget_basic_menu_link_myprofile { padding-top: 4px; padding-bottom: 4px; line-height: 32px; } -#evo_site_header .navbar .navbar-collapse .nav .login img { +#evo_site_header .navbar .navbar-collapse .nav .evo_widget_basic_menu_link_myprofile img { margin-right: 5px; border-radius: 4px; } @@ -47,7 +47,7 @@ #evo_site_header .navbar .navbar-collapse .nav.navbar-right li.evo_widget > a { display: inline-block; } - #evo_site_header .navbar .navbar-collapse .nav.navbar-right .login { + #evo_site_header .navbar .navbar-collapse .nav.navbar-right .evo_widget_basic_menu_link_myprofile { padding-top: 8px; padding-bottom: 9px; } diff --git a/skins/bootstrap_site_navbar_skin/style.less b/skins/bootstrap_site_navbar_skin/style.less index 0f4c5e5d00e..24a5d725677 100644 --- a/skins/bootstrap_site_navbar_skin/style.less +++ b/skins/bootstrap_site_navbar_skin/style.less @@ -24,7 +24,7 @@ padding-top: 9px; // Visual adaptation to the border-top } - .login { + .evo_widget_basic_menu_link_myprofile { padding-top: 4px; padding-bottom: 4px; line-height: 32px; @@ -60,7 +60,7 @@ li.evo_widget > a { display: inline-block; } - .login { + .evo_widget_basic_menu_link_myprofile { padding-top: 8px; padding-bottom: 9px; } diff --git a/skins/bootstrap_site_navbar_skin/style.min.css b/skins/bootstrap_site_navbar_skin/style.min.css index 1d454f1d216..5b158c7cc10 100644 --- a/skins/bootstrap_site_navbar_skin/style.min.css +++ b/skins/bootstrap_site_navbar_skin/style.min.css @@ -1 +1 @@ -#evo_site_header .navbar{margin-bottom:0}#evo_site_header .navbar .navbar-header.navbar-header-with-logo .navbar-brand{padding:0}#evo_site_header .navbar .navbar-header.navbar-header-with-logo .navbar-brand img{max-height:100%;max-width:270px}#evo_site_header .navbar .navbar-collapse{padding:0}#evo_site_header .navbar .navbar-collapse .nav{margin:0}#evo_site_header .navbar .navbar-collapse .nav.navbar-right{border-top:1px solid;padding-top:9px}#evo_site_header .navbar .navbar-collapse .nav .login{padding-top:4px;padding-bottom:4px;line-height:32px}#evo_site_header .navbar .navbar-collapse .nav .login img{margin-right:5px;border-radius:4px}#evo_site_header .level2 ul.nav.nav-pills{margin:15px 0}@media (min-width:768px){#evo_site_header .navbar .container-fluid.level1{padding-right:0}#evo_site_header .navbar .navbar-collapse .nav.navbar-left{margin-right:15px}#evo_site_header .navbar .navbar-collapse .nav.navbar-right{border-top:none;padding:0}#evo_site_header .navbar .navbar-collapse .nav.navbar-right li.evo_widget>a{display:inline-block}#evo_site_header .navbar .navbar-collapse .nav.navbar-right .login{padding-top:8px;padding-bottom:9px}}#evo_site_footer{background-color:#f5f5f5}#evo_site_footer p{margin:20px 0}.btn.slide-top{opacity:0;visibility:hidden;float:right;font-size:20px;position:fixed;padding:2px 13px;right:8px;top:8px;transition:all .3s;z-index:9999}.btn.slide-top.slide-top-visible{opacity:1;visibility:visible}.btn.slide-top.slide-top-toolbar{top:35px}.btn.slide-top.slide-top-fixed-header{top:50px}.btn.slide-top.slide-top-toolbar.slide-top-fixed-header{top:85px}@media only screen and (max-device-width:1024px){.btn.slide-top.slide-top-toolbar{top:8px}}@media (min-width:768px) and (max-width:991px) and (min-device-width:1024px){.btn.slide-top.slide-top-toolbar{top:35px}} \ No newline at end of file +#evo_site_header .navbar{margin-bottom:0}#evo_site_header .navbar .navbar-header.navbar-header-with-logo .navbar-brand{padding:0}#evo_site_header .navbar .navbar-header.navbar-header-with-logo .navbar-brand img{max-height:100%;max-width:270px}#evo_site_header .navbar .navbar-collapse{padding:0}#evo_site_header .navbar .navbar-collapse .nav{margin:0}#evo_site_header .navbar .navbar-collapse .nav.navbar-right{border-top:1px solid;padding-top:9px}#evo_site_header .navbar .navbar-collapse .nav .evo_widget_basic_menu_link_myprofile{padding-top:4px;padding-bottom:4px;line-height:32px}#evo_site_header .navbar .navbar-collapse .nav .evo_widget_basic_menu_link_myprofile img{margin-right:5px;border-radius:4px}#evo_site_header .level2 ul.nav.nav-pills{margin:15px 0}@media (min-width:768px){#evo_site_header .navbar .container-fluid.level1{padding-right:0}#evo_site_header .navbar .navbar-collapse .nav.navbar-left{margin-right:15px}#evo_site_header .navbar .navbar-collapse .nav.navbar-right{border-top:none;padding:0}#evo_site_header .navbar .navbar-collapse .nav.navbar-right li.evo_widget>a{display:inline-block}#evo_site_header .navbar .navbar-collapse .nav.navbar-right .evo_widget_basic_menu_link_myprofile{padding-top:8px;padding-bottom:9px}}#evo_site_footer{background-color:#f5f5f5}#evo_site_footer p{margin:20px 0}.btn.slide-top{opacity:0;visibility:hidden;float:right;font-size:20px;position:fixed;padding:2px 13px;right:8px;top:8px;transition:all .3s;z-index:9999}.btn.slide-top.slide-top-visible{opacity:1;visibility:visible}.btn.slide-top.slide-top-toolbar{top:35px}.btn.slide-top.slide-top-fixed-header{top:50px}.btn.slide-top.slide-top-toolbar.slide-top-fixed-header{top:85px}@media only screen and (max-device-width:1024px){.btn.slide-top.slide-top-toolbar{top:8px}}@media (min-width:768px) and (max-width:991px) and (min-device-width:1024px){.btn.slide-top.slide-top-toolbar{top:35px}} \ No newline at end of file diff --git a/skins/bootstrap_site_tabs_skin/_html_footer.inc.php b/skins/bootstrap_site_tabs_skin/_html_footer.inc.php index d0d25a6038b..9dbe926d521 100644 --- a/skins/bootstrap_site_tabs_skin/_html_footer.inc.php +++ b/skins/bootstrap_site_tabs_skin/_html_footer.inc.php @@ -12,6 +12,6 @@ - + - \ No newline at end of file + diff --git a/skins/bootstrap_site_tabs_skin/_site_body_header.inc.php b/skins/bootstrap_site_tabs_skin/_site_body_header.inc.php index 48d5670121c..bcabfbfaa1c 100644 --- a/skins/bootstrap_site_tabs_skin/_site_body_header.inc.php +++ b/skins/bootstrap_site_tabs_skin/_site_body_header.inc.php @@ -10,7 +10,7 @@ */ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); -global $baseurl, $Settings, $Blog, $disp, $current_User, $site_Skin; +global $baseurl, $Settings, $Blog, $disp, $site_Skin; $notification_logo_file_ID = intval( $Settings->get( 'notification_logo_file_ID' ) ); if( $notification_logo_file_ID > 0 && @@ -54,8 +54,8 @@ 'item_selected_start' => '', 'item_selected_end' => '', 'link_selected_class' => 'btn btn-default active btn-sm ', - 'link_default_class' => 'btn btn-default btn-sm ', - 'profile_menu_link_text' => 'avatar_force_login', + 'link_default_class' => 'btn btn-default btn-sm ', + 'link_text_myprofile' => '$login$', ) ); // ----------------------------- END OF "Right Navigation" CONTAINER ----------------------------- ?> @@ -82,7 +82,7 @@ foreach( $header_tabs as $s => $header_tab ) { // Display level 0 tabs: ?> - header_tab_active === $s ? ' class="active"' : '' ); ?>> + get_header_tab_attr_class( $header_tab, $s ); ?>> > - > + get_header_tab_attr_class( $menu_item ); ?>> > - - - \ No newline at end of file + diff --git a/skins/bootstrap_site_tabs_skin/_skin.class.php b/skins/bootstrap_site_tabs_skin/_skin.class.php index 925c4b8f322..34ecb931368 100644 --- a/skins/bootstrap_site_tabs_skin/_skin.class.php +++ b/skins/bootstrap_site_tabs_skin/_skin.class.php @@ -23,7 +23,7 @@ class bootstrap_site_tabs_Skin extends site_Skin * Skin version * @var string */ - var $version = '7.1.7'; + var $version = '7.2.5'; /** * Do we want to use style.min.css instead of style.css ? diff --git a/skins/bootstrap_site_tabs_skin/style.css b/skins/bootstrap_site_tabs_skin/style.css index 197a6e6cf3b..72fa45da0bb 100644 --- a/skins/bootstrap_site_tabs_skin/style.css +++ b/skins/bootstrap_site_tabs_skin/style.css @@ -102,11 +102,11 @@ div.level1 nav div.pull-right .btn { padding-top: 10px; padding-bottom: 10px; } -div.level1 nav div.pull-right .btn.login { +div.level1 nav div.pull-right .btn.evo_widget_basic_menu_link_myprofile { padding-top: 3px; padding-bottom: 3px; } -div.level1 nav div.pull-right .btn.login img { +div.level1 nav div.pull-right .btn.evo_widget_basic_menu_link_myprofile img { vertical-align: middle; } div.level1 nav div.pull-right .btn.btn-default { diff --git a/skins/bootstrap_site_tabs_skin/style.less b/skins/bootstrap_site_tabs_skin/style.less index 0ebd11eaf6d..eb254ae72dd 100644 --- a/skins/bootstrap_site_tabs_skin/style.less +++ b/skins/bootstrap_site_tabs_skin/style.less @@ -110,7 +110,7 @@ div.level1 { margin-left: 5px; padding-top: 10px; padding-bottom: 10px; - &.login { + &.evo_widget_basic_menu_link_myprofile { padding-top: 3px; padding-bottom: 3px; img { diff --git a/skins/bootstrap_site_tabs_skin/style.min.css b/skins/bootstrap_site_tabs_skin/style.min.css index bd4c8178a67..71949c95a54 100644 --- a/skins/bootstrap_site_tabs_skin/style.min.css +++ b/skins/bootstrap_site_tabs_skin/style.min.css @@ -1 +1 @@ -#evo_site_header{width:100%;font-family:Arial,Helvetica,sans-serif!important;display:table}#evo_site_header .swhead_sitename{vertical-align:middle;white-space:nowrap}#evo_site_header .swhead_sitename a{padding-left:10px;padding-right:10px;margin-right:2px}#evo_site_header .swhead_sitename.swhead_logo{display:table-cell;margin:-17px 0 -1px -6px}#evo_site_header .swhead_sitename.swhead_logo a{padding:0}#evo_site_header .swhead_sitename.swhead_logo img{max-height:60px;max-width:270px}#evo_site_header .swhead_menus{display:table-cell;width:100%}#evo_site_header .swhead_menus div.level1{background-color:#ddd}#evo_site_header .swhead_menus div.level1 nav .pull-right{margin-top:-10px}#evo_site_header .swhead_menus div.level1 nav .pull-right a{max-height:40px}#evo_site_header .swhead_menus div.level1 nav .pull-left li a{margin-right:0;border-color:#ddd;border-bottom:1px solid #ccc}#evo_site_header .swhead_menus div.level1 nav .pull-left li a:hover{background-color:#fff}#evo_site_header .swhead_menus div.level1 nav .pull-left li.swhead_sitename a{border:1px solid transparent}#evo_site_header .swhead_menus div.level1 nav .pull-left li.swhead_sitename a:hover{background-color:transparent}div.level1{padding-top:17px;padding-left:6px;background-color:#ddd;border-bottom:1px solid #ccc}div.level1 nav ul.nav.nav-tabs{margin:0;position:relative;top:1px;border-bottom:1px solid #ccc}div.level1 nav ul.nav.nav-tabs li{vertical-align:bottom;display:inline-block;float:none}div.level1 nav ul.nav.nav-tabs li a{transition:.1s ease}div.level1 nav ul.nav.nav-tabs li a:hover{border:1px solid #ccc}div.level1 nav ul.nav.nav-tabs li.active a{background:#fff;border-color:#ccc;border-bottom-color:#fff!important;cursor:pointer}div.level1 nav ul.nav.nav-tabs li.no_logo{padding-right:0;margin-right:0}div.level1 nav ul.nav.nav-tabs li.no_logo a{margin-right:0;background:0 0;font-weight:700;padding-left:0;padding-right:0;margin-right:10px}div.level1 nav ul.nav.nav-tabs li.no_logo a:hover{border:1px solid transparent}div.level1 nav div.pull-right .btn{margin-left:5px;padding-top:10px;padding-bottom:10px}div.level1 nav div.pull-right .btn.login{padding-top:3px;padding-bottom:3px}div.level1 nav div.pull-right .btn.login img{vertical-align:middle}div.level1 nav div.pull-right .btn.btn-default{transition:.1s ease}div.level1 nav div.pull-right .btn.btn-default:hover{border:1px solid #ccc}div.level2{padding:6px 15px 15px 6px;background:#fff}div.level2 nav .nav{margin:0}div.level2 nav .nav>li>a{padding:6px 10px 4px;font-size:92%;background-color:#eee}div.level2 nav .nav li{margin-right:4px}div.level2 nav .nav li.active a,div.level2 nav .nav li.active a:focus,div.level2 nav .nav li.active a:hover{background-color:#337ab7}@media (max-width:712px){.swhead_logo img{padding:21px 0 22px 2px!important}}.evo_post_title .btn-group a{padding-top:2px;padding-bottom:0}.pagination li a,.pagination li span{padding-top:7px;padding-bottom:5px}.pagination li a:last-child{padding-top:6px;padding-bottom:6px}.small.post_tags a{padding-top:3px;padding-bottom:2px}#evo_site_footer{color:#777;font-family:Arial,Helvetica,sans-serif!important;background:#f5f5f5}#evo_site_footer .container{padding:15px;text-align:center}#evo_site_footer .container p{margin-bottom:0}.btn.slide-top{opacity:0;visibility:hidden;float:right;font-size:20px;position:fixed;padding:2px 13px;right:8px;top:8px;transition:all .3s;z-index:9999}.btn.slide-top.slide-top-visible{opacity:1;visibility:visible}.btn.slide-top.slide-top-toolbar{top:35px}.btn.slide-top.slide-top-fixed-header{top:55px}.btn.slide-top.slide-top-toolbar.slide-top-fixed-header{top:90px}@media only screen and (max-device-width:1024px){.btn.slide-top.slide-top-toolbar{top:8px}}@media (min-width:768px) and (max-width:991px) and (min-device-width:1024px){.btn.slide-top.slide-top-toolbar{top:35px}} \ No newline at end of file +#evo_site_header{width:100%;font-family:Arial,Helvetica,sans-serif!important;display:table}#evo_site_header .swhead_sitename{vertical-align:middle;white-space:nowrap}#evo_site_header .swhead_sitename a{padding-left:10px;padding-right:10px;margin-right:2px}#evo_site_header .swhead_sitename.swhead_logo{display:table-cell;margin:-17px 0 -1px -6px}#evo_site_header .swhead_sitename.swhead_logo a{padding:0}#evo_site_header .swhead_sitename.swhead_logo img{max-height:60px;max-width:270px}#evo_site_header .swhead_menus{display:table-cell;width:100%}#evo_site_header .swhead_menus div.level1{background-color:#ddd}#evo_site_header .swhead_menus div.level1 nav .pull-right{margin-top:-10px}#evo_site_header .swhead_menus div.level1 nav .pull-right a{max-height:40px}#evo_site_header .swhead_menus div.level1 nav .pull-left li a{margin-right:0;border-color:#ddd;border-bottom:1px solid #ccc}#evo_site_header .swhead_menus div.level1 nav .pull-left li a:hover{background-color:#fff}#evo_site_header .swhead_menus div.level1 nav .pull-left li.swhead_sitename a{border:1px solid transparent}#evo_site_header .swhead_menus div.level1 nav .pull-left li.swhead_sitename a:hover{background-color:transparent}div.level1{padding-top:17px;padding-left:6px;background-color:#ddd;border-bottom:1px solid #ccc}div.level1 nav ul.nav.nav-tabs{margin:0;position:relative;top:1px;border-bottom:1px solid #ccc}div.level1 nav ul.nav.nav-tabs li{vertical-align:bottom;display:inline-block;float:none}div.level1 nav ul.nav.nav-tabs li a{transition:.1s ease}div.level1 nav ul.nav.nav-tabs li a:hover{border:1px solid #ccc}div.level1 nav ul.nav.nav-tabs li.active a{background:#fff;border-color:#ccc;border-bottom-color:#fff!important;cursor:pointer}div.level1 nav ul.nav.nav-tabs li.no_logo{padding-right:0;margin-right:0}div.level1 nav ul.nav.nav-tabs li.no_logo a{margin-right:0;background:0 0;font-weight:700;padding-left:0;padding-right:0;margin-right:10px}div.level1 nav ul.nav.nav-tabs li.no_logo a:hover{border:1px solid transparent}div.level1 nav div.pull-right .btn{margin-left:5px;padding-top:10px;padding-bottom:10px}div.level1 nav div.pull-right .btn.evo_widget_basic_menu_link_myprofile{padding-top:3px;padding-bottom:3px}div.level1 nav div.pull-right .btn.evo_widget_basic_menu_link_myprofile img{vertical-align:middle}div.level1 nav div.pull-right .btn.btn-default{transition:.1s ease}div.level1 nav div.pull-right .btn.btn-default:hover{border:1px solid #ccc}div.level2{padding:6px 15px 15px 6px;background:#fff}div.level2 nav .nav{margin:0}div.level2 nav .nav>li>a{padding:6px 10px 4px;font-size:92%;background-color:#eee}div.level2 nav .nav li{margin-right:4px}div.level2 nav .nav li.active a,div.level2 nav .nav li.active a:focus,div.level2 nav .nav li.active a:hover{background-color:#337ab7}@media (max-width:712px){.swhead_logo img{padding:21px 0 22px 2px!important}}.evo_post_title .btn-group a{padding-top:2px;padding-bottom:0}.pagination li a,.pagination li span{padding-top:7px;padding-bottom:5px}.pagination li a:last-child{padding-top:6px;padding-bottom:6px}.small.post_tags a{padding-top:3px;padding-bottom:2px}#evo_site_footer{color:#777;font-family:Arial,Helvetica,sans-serif!important;background:#f5f5f5}#evo_site_footer .container{padding:15px;text-align:center}#evo_site_footer .container p{margin-bottom:0}.btn.slide-top{opacity:0;visibility:hidden;float:right;font-size:20px;position:fixed;padding:2px 13px;right:8px;top:8px;transition:all .3s;z-index:9999}.btn.slide-top.slide-top-visible{opacity:1;visibility:visible}.btn.slide-top.slide-top-toolbar{top:35px}.btn.slide-top.slide-top-fixed-header{top:55px}.btn.slide-top.slide-top-toolbar.slide-top-fixed-header{top:90px}@media only screen and (max-device-width:1024px){.btn.slide-top.slide-top-toolbar{top:8px}}@media (min-width:768px) and (max-width:991px) and (min-device-width:1024px){.btn.slide-top.slide-top-toolbar{top:35px}} \ No newline at end of file diff --git a/skins/default_site_skin/_html_footer.inc.php b/skins/default_site_skin/_html_footer.inc.php index 8fcff8a7ea3..bbc8d442c17 100644 --- a/skins/default_site_skin/_html_footer.inc.php +++ b/skins/default_site_skin/_html_footer.inc.php @@ -12,6 +12,6 @@ - + - \ No newline at end of file + diff --git a/skins/default_site_skin/_site_body_header.inc.php b/skins/default_site_skin/_site_body_header.inc.php index 767b8744e1f..a247c28bff5 100644 --- a/skins/default_site_skin/_site_body_header.inc.php +++ b/skins/default_site_skin/_site_body_header.inc.php @@ -28,7 +28,7 @@ 'item_end' => '', 'item_selected_start' => '', 'item_selected_end' => '', - 'profile_menu_link_text' => 'avatar_force_login', + 'link_text_myprofile' => '$login$', ) ); // ----------------------------- END OF "Site Header" CONTAINER ----------------------------- diff --git a/skins/default_site_skin/_skin.class.php b/skins/default_site_skin/_skin.class.php index 2b622590092..aed5a7dcc81 100644 --- a/skins/default_site_skin/_skin.class.php +++ b/skins/default_site_skin/_skin.class.php @@ -21,7 +21,7 @@ class default_site_Skin extends Skin * Skin version * @var string */ - var $version = '7.1.7'; + var $version = '7.2.5'; /** * Do we want to use style.min.css instead of style.css ? diff --git a/skins/default_site_skin/style.css b/skins/default_site_skin/style.css index 8e4ebaab361..65cd786a768 100644 --- a/skins/default_site_skin/style.css +++ b/skins/default_site_skin/style.css @@ -62,13 +62,15 @@ body { filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#696c72', endColorstr='#333334'); font-weight: normal; } -#evo_site_header a.user { - color: #ccc; +#evo_site_header a.evo_widget_basic_menu_link_myprofile { position: relative; padding-left: 49px; +} +#evo_site_header a.evo_widget_basic_menu_link_myprofile .user { + color: #ccc; font-weight: normal; } -#evo_site_header a.user img { +#evo_site_header a.evo_widget_basic_menu_link_myprofile img { position: absolute; top: 0; left: 12px; @@ -100,7 +102,7 @@ body { padding: 0; display: inline-block; } -#evo_site_header .evo_widget.widget_core_msg_menu_link .badge { +#evo_site_header .evo_widget .evo_widget_basic_menu_link_messages .badge { margin-top: -3px; } #evo_site_header .evo_widget.widget_core_site_logo a:hover { diff --git a/skins/default_site_skin/style.less b/skins/default_site_skin/style.less index b0664023c69..10273279e2c 100644 --- a/skins/default_site_skin/style.less +++ b/skins/default_site_skin/style.less @@ -66,11 +66,13 @@ body { filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#696c72', endColorstr='#333334'); font-weight: normal; } - &.user { - color: #ccc; // Don't use a color for user names in the header site menu + &.evo_widget_basic_menu_link_myprofile { position: relative; padding-left: 49px; - font-weight: normal; + .user { + color: #ccc; // Don't use a color for user names in the header site menu + font-weight: normal; + } img { position: absolute; top: 0; @@ -105,7 +107,7 @@ body { .evo_widget { padding: 0; display: inline-block; - &.widget_core_msg_menu_link .badge { + .evo_widget_basic_menu_link_messages .badge { margin-top: -3px; } &.widget_core_site_logo a:hover { diff --git a/skins/default_site_skin/style.min.css b/skins/default_site_skin/style.min.css index eaf9ac3570e..4faa8ffb87e 100644 --- a/skins/default_site_skin/style.min.css +++ b/skins/default_site_skin/style.min.css @@ -1 +1 @@ -body{margin:0;padding:0}.floatright{float:right}#evo_site_footer,#evo_site_header{font-family:HelveticaNeue-Light,"Helvetica Neue Light","Helvetica Neue",Helvetica,Arial;line-height:normal;color:#ccc;margin:0;clear:both}#evo_site_header{font-size:16px;font-weight:300;text-align:left;box-shadow:0 -1px 8px 4px rgba(0,0,0,.5);padding:0;background:-webkit-linear-gradient(top,#595c64,#1b1b1c);background:-moz-linear-gradient(top,#595c64,#1b1b1c);background:-ms-linear-gradient(top,#595c64,#1b1b1c);border-bottom:1px solid #666}#evo_site_header label[for=nav-trigger]{position:relative;top:10px;left:0;width:24px;height:24px;cursor:pointer;background-color:#ccc;-webkit-mask:url("data:image/svg+xml;utf8, ");mask:url("data:image/svg+xml;utf8, ");background-size:contain;margin:1px 10px 1px 5px}#evo_site_header a{color:#ccc;border:none;display:inline-block;padding:12px;text-decoration:none}#evo_site_header a.selected,#evo_site_header a:hover{text-decoration:none;text-shadow:0 0 3px #fff;color:#fff;background:-webkit-linear-gradient(top,#696c72,#333334);background:-moz-linear-gradient(top,#696c72,#333334);background:-ms-linear-gradient(top,#696c72,#333334);font-weight:400}#evo_site_header a.user{color:#ccc;position:relative;padding-left:49px;font-weight:400}#evo_site_header a.user img{position:absolute;top:0;left:12px;bottom:0;margin:auto}#evo_site_header a.evo_widget__site_logo_text{color:#fff;font-weight:400}#evo_site_header .floatright a.selected,#evo_site_header .floatright a:hover{text-decoration:underline;background:0 0;text-shadow:none;filter:none}#evo_site_header a.bg-white{border-radius:3px;padding:8px 9px;margin-right:15px;color:#000;background:#fff}#evo_site_header a.bg-white:hover{background:#fff}#evo_site_header .evo_widget{padding:0;display:inline-block}#evo_site_header .evo_widget.widget_core_msg_menu_link .badge{margin-top:-3px}#evo_site_header .evo_widget.widget_core_site_logo a:hover{text-decoration:none;text-shadow:0 0 3px #fff;color:#fff}input#nav-trigger{position:absolute;clip:rect(0,0,0,0)}.evo_container__navigation_hamburger{background-color:#1b1b1c;height:auto;max-height:0;overflow-y:auto}.evo_container__navigation_hamburger .evo_navigation_hamburger_list{margin:0;padding:0;list-style:none;text-align:right;z-index:1}.evo_container__navigation_hamburger .evo_navigation_hamburger_list>li{padding:0;display:block}.evo_container__navigation_hamburger .evo_navigation_hamburger_list>li:hover{text-decoration:none;text-shadow:0 0 3px #fff;color:#fff;background:-ms-linear-gradient(top,#696c72,#333334)}.evo_container__navigation_hamburger .evo_navigation_hamburger_list a.default,.evo_container__navigation_hamburger .evo_navigation_hamburger_list a.selected{color:#ccc;font-size:16px;font-weight:300;display:block;padding:5px 12px}.evo_container__navigation_hamburger .evo_navigation_hamburger_list a.selected{text-decoration:none;text-shadow:0 0 3px #fff;color:#fff;background:-webkit-linear-gradient(top,#696c72,#333334);background:-moz-linear-gradient(top,#696c72,#333334);background:-ms-linear-gradient(top,#696c72,#333334);width:100%}.evo_container__navigation_hamburger .evo_navigation_hamburger_list a:hover{text-decoration:none}.evo_container__navigation_hamburger .evo_navigation_hamburger_list a.bg-white{border-radius:3px;padding:8px 9px;margin:4px 10px;display:inline-block;color:#000;background:#fff}.evo_container__navigation_hamburger .evo_navigation_hamburger_list a.bg-white:hover{background:#fff}.evo_container__navigation_hamburger .evo_navigation_hamburger_list hr{margin:0;border-color:#696c72}.evo_container__navigation_hamburger .evo_navigation_hamburger_list a.evo_widget__site_logo_image{padding:0}.evo_container__navigation_hamburger .evo_navigation_hamburger_list a.evo_widget__site_logo_image img{max-height:42px;max-width:270px}.nav-trigger:checked~.evo_container__navigation_hamburger{max-height:1000px}.nav-trigger+.evo_container__navigation_hamburger{transition:max-height .5s ease-in-out}@media only screen and (max-device-width:1024px){div#skin_wrapper #evo_site_header{position:inherit;width:100%}}#evo_site_footer{font-size:11px;text-align:center;border-top:1px solid #444;box-shadow:inset 0 1px 2px rgba(0,0,0,.3);padding:4px;background-color:#888}#evo_site_footer a{text-decoration:underline;color:#ccc;border:none} \ No newline at end of file +body{margin:0;padding:0}.floatright{float:right}#evo_site_footer,#evo_site_header{font-family:HelveticaNeue-Light,"Helvetica Neue Light","Helvetica Neue",Helvetica,Arial;line-height:normal;color:#ccc;margin:0;clear:both}#evo_site_header{font-size:16px;font-weight:300;text-align:left;box-shadow:0 -1px 8px 4px rgba(0,0,0,.5);padding:0;background:-webkit-linear-gradient(top,#595c64,#1b1b1c);background:-moz-linear-gradient(top,#595c64,#1b1b1c);background:-ms-linear-gradient(top,#595c64,#1b1b1c);border-bottom:1px solid #666}#evo_site_header label[for=nav-trigger]{position:relative;top:10px;left:0;width:24px;height:24px;cursor:pointer;background-color:#ccc;-webkit-mask:url("data:image/svg+xml;utf8, ");mask:url("data:image/svg+xml;utf8, ");background-size:contain;margin:1px 10px 1px 5px}#evo_site_header a{color:#ccc;border:none;display:inline-block;padding:12px;text-decoration:none}#evo_site_header a.selected,#evo_site_header a:hover{text-decoration:none;text-shadow:0 0 3px #fff;color:#fff;background:-webkit-linear-gradient(top,#696c72,#333334);background:-moz-linear-gradient(top,#696c72,#333334);background:-ms-linear-gradient(top,#696c72,#333334);font-weight:400}#evo_site_header a.evo_widget_basic_menu_link_myprofile{position:relative;padding-left:49px}#evo_site_header a.evo_widget_basic_menu_link_myprofile .user{color:#ccc;font-weight:400}#evo_site_header a.evo_widget_basic_menu_link_myprofile img{position:absolute;top:0;left:12px;bottom:0;margin:auto}#evo_site_header a.evo_widget__site_logo_text{color:#fff;font-weight:400}#evo_site_header .floatright a.selected,#evo_site_header .floatright a:hover{text-decoration:underline;background:0 0;text-shadow:none;filter:none}#evo_site_header a.bg-white{border-radius:3px;padding:8px 9px;margin-right:15px;color:#000;background:#fff}#evo_site_header a.bg-white:hover{background:#fff}#evo_site_header .evo_widget{padding:0;display:inline-block}#evo_site_header .evo_widget .evo_widget_basic_menu_link_messages .badge{margin-top:-3px}#evo_site_header .evo_widget.widget_core_site_logo a:hover{text-decoration:none;text-shadow:0 0 3px #fff;color:#fff}input#nav-trigger{position:absolute;clip:rect(0,0,0,0)}.evo_container__navigation_hamburger{background-color:#1b1b1c;height:auto;max-height:0;overflow-y:auto}.evo_container__navigation_hamburger .evo_navigation_hamburger_list{margin:0;padding:0;list-style:none;text-align:right;z-index:1}.evo_container__navigation_hamburger .evo_navigation_hamburger_list>li{padding:0;display:block}.evo_container__navigation_hamburger .evo_navigation_hamburger_list>li:hover{text-decoration:none;text-shadow:0 0 3px #fff;color:#fff;background:-ms-linear-gradient(top,#696c72,#333334)}.evo_container__navigation_hamburger .evo_navigation_hamburger_list a.default,.evo_container__navigation_hamburger .evo_navigation_hamburger_list a.selected{color:#ccc;font-size:16px;font-weight:300;display:block;padding:5px 12px}.evo_container__navigation_hamburger .evo_navigation_hamburger_list a.selected{text-decoration:none;text-shadow:0 0 3px #fff;color:#fff;background:-webkit-linear-gradient(top,#696c72,#333334);background:-moz-linear-gradient(top,#696c72,#333334);background:-ms-linear-gradient(top,#696c72,#333334);width:100%}.evo_container__navigation_hamburger .evo_navigation_hamburger_list a:hover{text-decoration:none}.evo_container__navigation_hamburger .evo_navigation_hamburger_list a.bg-white{border-radius:3px;padding:8px 9px;margin:4px 10px;display:inline-block;color:#000;background:#fff}.evo_container__navigation_hamburger .evo_navigation_hamburger_list a.bg-white:hover{background:#fff}.evo_container__navigation_hamburger .evo_navigation_hamburger_list hr{margin:0;border-color:#696c72}.evo_container__navigation_hamburger .evo_navigation_hamburger_list a.evo_widget__site_logo_image{padding:0}.evo_container__navigation_hamburger .evo_navigation_hamburger_list a.evo_widget__site_logo_image img{max-height:42px;max-width:270px}.nav-trigger:checked~.evo_container__navigation_hamburger{max-height:1000px}.nav-trigger+.evo_container__navigation_hamburger{transition:max-height .5s ease-in-out}@media only screen and (max-device-width:1024px){div#skin_wrapper #evo_site_header{position:inherit;width:100%}}#evo_site_footer{font-size:11px;text-align:center;border-top:1px solid #444;box-shadow:inset 0 1px 2px rgba(0,0,0,.3);padding:4px;background-color:#888}#evo_site_footer a{text-decoration:underline;color:#ccc;border:none} \ No newline at end of file diff --git a/skins/green_bootstrap_theme/_skin.class.php b/skins/green_bootstrap_theme/_skin.class.php index 3645cc9738f..682135a4d28 100644 --- a/skins/green_bootstrap_theme/_skin.class.php +++ b/skins/green_bootstrap_theme/_skin.class.php @@ -23,7 +23,7 @@ class green_bootstrap_theme_Skin extends Skin * Skin version * @var string */ - var $version = '7.1.7'; + var $version = '7.2.5'; /** * Do we want to use style.min.css instead of style.css ? @@ -889,6 +889,12 @@ function get_param_definitions_forum( $params ) ), 'type' => 'select', ), + 'sidebar_general_affix' => array( + 'label' => T_('Fixed position for General Sidebar'), + 'note' => T_('Use affix to keep visible when scrolling down.'), + 'type' => 'checkbox', + 'defaultvalue' => 0, + ), 'layout_single' => array( 'label' => T_('Single Thread Layout'), 'note' => T_('Select skin layout for single threads') . ' (disp=single).', @@ -900,6 +906,12 @@ function get_param_definitions_forum( $params ) ), 'type' => 'select', ), + 'sidebar_single_affix' => array( + 'label' => T_('Fixed position for Single Sidebar'), + 'note' => T_('Use affix to keep visible when scrolling down.'), + 'type' => 'checkbox', + 'defaultvalue' => 1, + ), 'main_content_image_size' => array( 'label' => T_('Image size for main content'), 'note' => T_('Controls Aspect, Ratio and Standard Size'), @@ -907,12 +919,6 @@ function get_param_definitions_forum( $params ) 'options' => get_available_thumb_sizes(), 'type' => 'select', ), - 'sidebar_single_affix' => array( - 'label' => T_('Sidebar Single'), - 'note' => T_('Use affix to keep visible when scrolling down.'), - 'type' => 'checkbox', - 'defaultvalue' => 1, - ), 'max_image_height' => array( 'label' => T_('Max image height'), 'input_suffix' => ' px ', @@ -1289,14 +1295,10 @@ function display_init() { // Request some common features that the parent function (Skin::display_init()) knows how to provide: parent::display_init( array( - 'jquery', // Load jQuery - 'font_awesome', // Load Font Awesome (and use its icons as a priority over the Bootstrap glyphicons) - 'bootstrap', // Load Bootstrap (without 'bootstrap_theme_css') - 'bootstrap_evo_css', // Load the b2evo_base styles for Bootstrap (instead of the old b2evo_base styles) + 'superbundle', // Load general front-office JS + bundled jQuery and Bootstrap 'bootstrap_messages', // Initialize $Messages Class to use Bootstrap styles 'style_css', // Load the style.css file of the current skin 'colorbox', // Load Colorbox (a lightweight Lightbox alternative + customizations for b2evo) - 'bootstrap_init_tooltips', // Inline JS to init Bootstrap tooltips (E.g. on comment form for allowed file extensions) 'disp_auto', // Automatically include additional CSS and/or JS required by certain disps (replace with 'disp_off' to disable this) ) ); } @@ -1668,12 +1670,12 @@ function display_init_forum() if( in_array( $disp, array( 'single', 'page', 'comments' ) ) ) { // Load jquery UI to animate background color on change comment status or on vote - require_js( '#jqueryUI#', 'blog' ); + require_js_defer( '#jqueryUI#', 'blog' ); } if( in_array( $disp, array( 'single', 'page' ) ) ) { // Init JS to autcomplete the user logins - require_js( '#bootstrap_typeahead#', 'blog' ); + require_js_defer( '#bootstrap_typeahead#', 'blog' ); init_autocomplete_login_js( 'blog', 'typeahead' ); // Initialize date picker for _item_expert.form.php init_datepicker_js( 'blog' ); @@ -1712,6 +1714,12 @@ function display_init_forum() '; add_headline( $custom_css ); } + + if( ( $this->get_setting( 'sidebar_general_affix' ) && $this->is_visible_sidebar_forums( true, 'general' ) ) || + ( $this->get_setting( 'sidebar_single_affix' ) && $this->is_visible_sidebar_forums( true, 'single' ) ) ) + { // Init JS to fix sidebars on scroll down: + require_js_defer( 'src/evo_affix_sidebars.js', 'blog', false, '#', 'footerlines' ); + } } @@ -1742,9 +1750,6 @@ function display_init_manual() case 'front': // Init star rating for intro posts: init_ratings_js( 'blog', true ); - - // Used to quick upload several files: - init_fileuploader_js( 'blog' ); break; case 'posts': @@ -1762,15 +1767,12 @@ function display_init_manual() $bootstrap_manual_posts_text = $Chapter->get( 'name' ); } } - - // Used to quick upload several files for comment of intro post: - init_fileuploader_js( 'blog' ); break; } if( $this->is_side_navigation_visible() ) { // Include JS code for left navigation panel only when it is displayed: - $this->require_js( 'manual/affix_sidebars.js' ); + $this->require_js_defer( 'left_navigation.js' ); } // Init JS to affix Messages: @@ -2321,7 +2323,7 @@ function get_post_button( $chapter_ID, $Item = NULL, $params = array() ) */ function display_posts_list_header( $title, $params = array() ) { - global $Blog, $current_User; + global $Blog; $params = array_merge( array( 'actions' => '', @@ -2339,20 +2341,18 @@ function display_posts_list_header( $title, $params = array() ) 'after_workflow_header' => '
      ', 'before_workflow_title' => '
      ', 'after_workflow_title' => '
      ', - 'before_workflow_status' => '
      ', + 'before_workflow_status' => '
      ', 'after_workflow_status' => '
      ', - 'before_workflow_actions' => '
      ', + 'before_workflow_actions' => '
      ', 'after_workflow_actions' => '
      ', ), $params ); // Check if current User can view workflow properties: $can_view_workflow = - // User must be logged in: - is_logged_in() && // Workflow must be enabled for current Collection: $Blog->get_setting( 'use_workflow' ) && // Current User must has a permission to be assigned for tasks of the current Collection: - $current_User->check_perm( 'blog_can_be_assignee', 'edit', false, $Blog->ID ); + check_user_perm( 'blog_can_be_assignee', 'edit', false, $Blog->ID ); // Get template depending on permission of current User: $template = ( $can_view_workflow ? 'workflow' : 'normal' ); @@ -2382,7 +2382,7 @@ function display_posts_list_header( $title, $params = array() ) .$ItemStatusCache->get_option_list( $status ) .''; // JavaScript to reload page with new selected task status: - echo ''; + ';*/ echo $params['after_workflow_status']; } @@ -2527,4 +2527,4 @@ function get_layout_class( $place ) } } -?> \ No newline at end of file +?> diff --git a/skins/green_bootstrap_theme/forum/_front.disp.php b/skins/green_bootstrap_theme/forum/_front.disp.php index f5027bdb55a..6b1eb22f29a 100644 --- a/skins/green_bootstrap_theme/forum/_front.disp.php +++ b/skins/green_bootstrap_theme/forum/_front.disp.php @@ -44,9 +44,8 @@ } // ------------------------------- START OF POSTS ASSIGNED TO CURRENT USER ------------------------------- -if( is_logged_in() && - $Blog->get_setting( 'use_workflow' ) && - $current_User->check_perm( 'blog_can_be_assignee', 'edit', false, $Blog->ID ) ) +if( $Blog->get_setting( 'use_workflow' ) && + check_user_perm( 'blog_can_be_assignee', 'edit', false, $Blog->ID ) ) { // Only if current User can be assigned to tasks of the current Collection: $assigned_ItemList = new ItemList2( $Blog, NULL, NULL, 15, 'ItemCache', 'assigned_' ); $assigned_ItemList->set_filters( array( diff --git a/skins/green_bootstrap_theme/forum/_item_block.inc.php b/skins/green_bootstrap_theme/forum/_item_block.inc.php index 5b9f974ae93..8c419645bc6 100644 --- a/skins/green_bootstrap_theme/forum/_item_block.inc.php +++ b/skins/green_bootstrap_theme/forum/_item_block.inc.php @@ -14,7 +14,7 @@ */ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); -global $Item, $preview, $dummy_fields, $cat, $current_User, $app_version; +global $Item, $preview, $dummy_fields, $cat, $app_version; /** * @var array Save all statuses that used on this page in order to show them in the footer legend @@ -141,7 +141,7 @@
      -
      +
      @@ -402,15 +402,19 @@
      is_visible_sidebar( false, 'single' ) ) + if( $Skin->is_visible_sidebar_forums( false, 'single' ) ) { // Display sidebar: + ?> + +
      - - + diff --git a/skins/green_bootstrap_theme/forum/_item_comment.inc.php b/skins/green_bootstrap_theme/forum/_item_comment.inc.php index 26dba4883b0..c58518efa5f 100644 --- a/skins/green_bootstrap_theme/forum/_item_comment.inc.php +++ b/skins/green_bootstrap_theme/forum/_item_comment.inc.php @@ -315,7 +315,7 @@ echo '
      '; $Comment->edit_link( ' ', '', '#', T_('Edit this reply'), button_class( 'text' ).' comment_edit_btn', '&', true, $comment_redirect_url ); /* Link for editing */ echo ''; - $delete_button_is_displayed = is_logged_in() && $current_User->check_perm( 'comment!CURSTATUS', 'delete', false, $Comment ); + $delete_button_is_displayed = check_user_perm( 'comment!CURSTATUS', 'delete', false, $Comment ); $Comment->moderation_links( array( 'ajax_button' => true, 'class' => button_class( 'text' ), diff --git a/skins/green_bootstrap_theme/forum/_item_content.inc.php b/skins/green_bootstrap_theme/forum/_item_content.inc.php index ff137966b6c..ba660b1bff7 100644 --- a/skins/green_bootstrap_theme/forum/_item_content.inc.php +++ b/skins/green_bootstrap_theme/forum/_item_content.inc.php @@ -123,7 +123,7 @@ if( $params['include_cover_images'] ) { // Include the cover images on teaser place - $teaser_image_positions = 'cover,teaser,teaserperm,teaserlink'; + $teaser_image_positions = 'cover,background,teaser,teaserperm,teaserlink'; } else { // Don't include the cover images @@ -162,7 +162,7 @@ 'gallery_image_limit' => $params['gallery_image_limit'], 'gallery_colls' => $params['gallery_colls'], 'gallery_order' => $params['gallery_order'], - // Optionally restrict to files/images linked to specific position: 'teaser'|'teaserperm'|'teaserlink'|'aftermore'|'inline'|'cover' + // Optionally restrict to files/images linked to specific position: 'teaser'|'teaserperm'|'teaserlink'|'aftermore'|'inline'|'cover'|'background' 'restrict_to_image_position' => $teaser_image_positions, ) ); } @@ -214,7 +214,7 @@ 'gallery_image_limit' => $params['gallery_image_limit'], 'gallery_colls' => $params['gallery_colls'], 'gallery_order' => $params['gallery_order'], - // Optionally restrict to files/images linked to specific position: 'teaser'|'teaserperm'|'teaserlink'|'aftermore'|'inline'|'cover' + // Optionally restrict to files/images linked to specific position: 'teaser'|'teaserperm'|'teaserlink'|'aftermore'|'inline'|'cover'|'background' 'restrict_to_image_position' => $teaser_image_positions, ) ); } @@ -291,7 +291,7 @@ 'gallery_image_limit' => $params['gallery_image_limit'], 'gallery_colls' => $params['gallery_colls'], 'gallery_order' => $params['gallery_order'], - // Optionally restrict to files/images linked to specific position: 'teaser'|'teaserperm'|'teaserlink'|'aftermore'|'inline'|'cover' + // Optionally restrict to files/images linked to specific position: 'teaser'|'teaserperm'|'teaserlink'|'aftermore'|'inline'|'cover'|'background' 'restrict_to_image_position' => 'aftermore', ) ); } diff --git a/skins/green_bootstrap_theme/forum/_item_list.inc.php b/skins/green_bootstrap_theme/forum/_item_list.inc.php index d15c74a8a4f..cbda4e26e95 100644 --- a/skins/green_bootstrap_theme/forum/_item_list.inc.php +++ b/skins/green_bootstrap_theme/forum/_item_list.inc.php @@ -65,12 +65,10 @@ } // There is a very restrictive case in which we display workflow: $display_workflow = - // User must be logged in: - is_logged_in() && // Workflow must be enabled for current Collection: $Item->get_coll_setting( 'use_workflow' ) && // Current User must has a permission to be assigned for tasks of the current Collection: - $current_User->check_perm( 'blog_can_be_assignee', 'edit', false, $Item->get_blog_ID() ); + check_user_perm( 'blog_can_be_assignee', 'edit', false, $Item->get_blog_ID() ); ?>
      diff --git a/skins/green_bootstrap_theme/forum/_posts.disp.php b/skins/green_bootstrap_theme/forum/_posts.disp.php index e2eb7aad6c7..c4caed1c1e8 100644 --- a/skins/green_bootstrap_theme/forum/_posts.disp.php +++ b/skins/green_bootstrap_theme/forum/_posts.disp.php @@ -64,17 +64,9 @@ $Item = & get_featured_Item( 'posts', NULL, false, ( isset( $tag ) || $single_cat_ID ? false : NULL ) ) ) { // We have a intro post to display: $featured_item_ID = $Item->ID; - $intro_item_style = ''; - $LinkOwner = new LinkItem( $Item ); - $LinkList = $LinkOwner->get_attachment_LinkList( 1, 'cover' ); - if( ! empty( $LinkList ) && - $Link = & $LinkList->get_next() && - $File = & $Link->get_File() && - $File->exists() && - $File->is_image() ) - { // Use cover image of intro-post as background: - $intro_item_style = 'background-image: url("'.$File->get_url().'")'; - } + // Use background position image of intro-post for background URL: + $background_image_url = $Item->get_cover_image_url( 'background' ); + $intro_item_style = $background_image_url ? 'background-image: url("'.$background_image_url.'")' : ''; // ---------------------- ITEM BLOCK INCLUDED HERE ------------------------ skin_include( '_item_block_intro.inc.php', array( 'content_mode' => 'full', // We want regular "full" content, even in category browsing: i-e no excerpt or thumbnail diff --git a/skins/green_bootstrap_theme/forum/_search.disp.php b/skins/green_bootstrap_theme/forum/_search.disp.php index 92ca5731153..a4d96301446 100644 --- a/skins/green_bootstrap_theme/forum/_search.disp.php +++ b/skins/green_bootstrap_theme/forum/_search.disp.php @@ -23,7 +23,7 @@ widget_container( 'search_area', array( // The following params will be used as defaults for widgets included in this container: 'container_display_if_empty' => false, // If no widget, don't display container at all - 'container_start' => '
      ', + 'container_start' => '
      ', 'container_end' => '
      ', 'block_start' => '
      ', 'block_end' => '
      ', diff --git a/skins/green_bootstrap_theme/forum/index.main.php b/skins/green_bootstrap_theme/forum/index.main.php index 8f9f6346c31..0c3427f6734 100644 --- a/skins/green_bootstrap_theme/forum/index.main.php +++ b/skins/green_bootstrap_theme/forum/index.main.php @@ -137,7 +137,7 @@
      -
      +
      @@ -168,11 +168,13 @@ 'title_after' => '', 'title_single_disp' => false, 'title_page_disp' => false, + 'title_widget_page_disp' => false, 'format' => 'htmlbody', 'category_text' => '', 'categories_text' => '', 'catdir_text' => '', - 'comments_text' => T_('Latest Replies'), + 'comments_text' => '', + 'search_text' => '', 'front_text' => '', 'posts_text' => '', 'flagged_text' => '', @@ -285,11 +287,12 @@ is_visible_sidebar() ) + if( $Skin->is_visible_sidebar_forums() ) { // Display sidebar: ?> @@ -391,76 +395,80 @@ } ?> -