/** * Display the end of a payload block * * Note: it is possible to display several payload blocks on a single page. * The first block uses the "sub" template, the others "block". * @see disp_payload_begin() */ function disp_payload_end() { if (is_ajax_content()) { // Don't display this content on AJAX request return; } if (empty($this->displayed_sub_end)) { $name = 'sub'; $this->displayed_sub_end = 1; } else { $name = 'block'; } $template = $this->get_template($name); echo $template['end']; }
/** * Template tag. * * @param string Template name * @param array Params * @param boolean force include even if sitewide header/footer not enabled */ function siteskin_include($template_name, $params = array(), $force = false) { global $Settings, $siteskins_path, $Blog; if (!$Settings->get('site_skins_enabled') && !$force) { // Site skins are not enabled and we don't want to force either return; } if (is_ajax_content($template_name)) { // When we request ajax content for results table we need to hide wrapper data (header, footer & etc) return; } // Globals that may be needed by the template: global $current_User, $Hit, $Session, $Settings; global $skin_url, $htsrv_url, $htsrv_url_sensitive; global $samedomain_htsrv_url, $secure_htsrv_url; global $credit_links, $skin_links, $francois_links, $fplanque_links, $skinfaktory_links; /** * @var Log */ global $Debuglog; global $Timer; $timer_name = 'siteskin_include(' . $template_name . ')'; $Timer->resume($timer_name); if (file_exists($siteskins_path . 'custom/' . $template_name)) { // Use the custom template: $file = $siteskins_path . 'custom/' . $template_name; $debug_info = '<b>Custom template</b>: ' . rel_path_to_base($file); $disp_handled = 'custom'; } elseif (file_exists($siteskins_path . $template_name)) { // Use the default/fallback template: $file = $siteskins_path . $template_name; $debug_info = '<b>Fallback to</b>: ' . rel_path_to_base($file); $disp_handled = 'fallback'; } else { $disp_handled = false; } // Do we want a visible container for DEBUG/DEV ?: if (strpos($template_name, '_html_') !== false || strpos($template_name, '_init.') !== false) { // We're outside of the page body: NEVER display wrap this include with a <div> $display_includes = false; } elseif (isset($Session)) { // We may wrap with a <div>: $display_includes = $Session->get('display_includes_' . (empty($Blog) ? 0 : $Blog->ID)) == 1; } else { // Request without defined $Session, Don't display the includes: $display_includes = false; } if ($display_includes) { // Wrap the include with a visible div: echo '<div class="dev-blocks dev-blocks--siteinclude">'; echo '<div class="dev-blocks-name">siteskin_include( <b>' . $template_name . '</b> ) -> ' . $debug_info . '</div>'; } if ($disp_handled) { $Debuglog->add('siteskin_include: ' . rel_path_to_base($file), 'skins'); require $file; } else { // nothing handled the display printf('<div class="skin_error">Site template [%s] not found.</div>', $template_name); if (!empty($current_User) && $current_User->level == 10) { printf('<div class="skin_error">User level 10 help info: [%s]</div>', $siteskins_path . $template_name); } } if ($display_includes) { // End of visible container: // echo get_icon( 'pixel', 'imgtag', array( 'class' => 'clear' ) ); echo '</div>'; } $Timer->pause($timer_name); }
/** * Display threads results table * * @param array Params */ function threads_results_block($params = array()) { // Make sure we are not missing any param: $params = array_merge(array('edited_User' => NULL, 'results_param_prefix' => 'actv_thrd_', 'results_title' => T_('Threads with private messages sent by the user'), 'results_no_text' => T_('User has not sent any private messages')), $params); if (!is_logged_in()) { // Only logged in users can access to this function return; } global $current_User; if (!$current_User->check_perm('users', 'edit') || !$current_User->check_perm('perm_messaging', 'reply')) { // Check minimum permission: return; } $edited_User = $params['edited_User']; if (!$edited_User) { // No defined User, probably the function is calling from AJAX request $user_ID = param('user_ID', 'integer', 0); if (empty($user_ID)) { // Bad request, Exit here return; } $UserCache =& get_UserCache(); if (($edited_User =& $UserCache->get_by_ID($user_ID, false)) === false) { // Bad request, Exit here return; } } global $DB, $current_User; param('user_tab', 'string', '', true); param('user_ID', 'integer', 0, true); // Check permission: if ($current_User->check_perm('perm_messaging', 'abuse')) { // Create result set: $threads_Results = get_threads_results(array('results_param_prefix' => $params['results_param_prefix'], 'user_ID' => $edited_User->ID, 'sent_user_ID' => $edited_User->ID)); $threads_Results->Cache =& get_ThreadCache(); $threads_Results->title = $params['results_title']; $threads_Results->no_results_text = $params['results_no_text']; if ($threads_Results->total_rows > 0) { // Display action icon to delete all records if at least one record exists $threads_Results->global_icon(sprintf(T_('Delete all private messages sent by %s'), $edited_User->login), 'delete', '?ctrl=user&user_tab=activity&action=delete_all_messages&user_ID=' . $edited_User->ID . '&' . url_crumb('user'), ' ' . T_('Delete all'), 3, 4); } // Load classes load_class('messaging/model/_thread.class.php', 'Thread'); // Initialize Results object threads_results($threads_Results, array('abuse_management' => 1, 'show_only_date' => 1)); if (is_ajax_content()) { // init results param by template name if (!isset($params['skin_type']) || !isset($params['skin_name'])) { debug_die('Invalid ajax results request!'); } $threads_Results->init_params_by_skin($params['skin_type'], $params['skin_name']); } $display_params = array('before' => '<div class="results" style="margin-top:25px" id="threads_result">'); $threads_Results->display($display_params); if (!is_ajax_content()) { // Create this hidden div to get a function name for AJAX request echo '<div id="' . $params['results_param_prefix'] . 'ajax_callback" style="display:none">' . __FUNCTION__ . '</div>'; } } else { // No permission for abuse management echo '<div style="margin-top:25px;font-weight:bold">' . sprintf(T_('User has sent %s private messages'), $edited_User->get_num_messages('sent')) . '</div>'; } }
/** * Template tag. Include a sub-template at the current position * */ function skin_include($template_name, $params = array()) { if (is_ajax_content($template_name)) { // When we request ajax content for results table we need to hide wrapper data (header, footer & etc) return; } global $skins_path, $ads_current_skin_path, $disp; // Globals that may be needed by the template: global $Blog, $MainList, $Item; global $Plugins, $Skin; global $current_User, $Hit, $Session, $Settings; global $skin_url, $htsrv_url, $htsrv_url_sensitive; global $samedomain_htsrv_url, $secure_htsrv_url; global $credit_links, $skin_links, $francois_links, $fplanque_links, $skinfaktory_links; /** * @var Log */ global $Debuglog; global $Timer; $timer_name = 'skin_include(' . $template_name . ')'; $Timer->resume($timer_name); if ($template_name == '$disp$') { // This is a special case. // We are going to include a template based on $disp: // Default display handlers: $disp_handlers = array('disp_404' => '_404_not_found.disp.php', 'disp_arcdir' => '_arcdir.disp.php', 'disp_catdir' => '_catdir.disp.php', 'disp_comments' => '_comments.disp.php', 'disp_feedback-popup' => '_feedback_popup.disp.php', 'disp_help' => '_help.disp.php', 'disp_login' => '_login.disp.php', 'disp_register' => '_register.disp.php', 'disp_activateinfo' => '_activateinfo.disp.php', 'disp_lostpassword' => '_lostpassword.disp.php', 'disp_mediaidx' => '_mediaidx.disp.php', 'disp_msgform' => '_msgform.disp.php', 'disp_threads' => '_threads.disp.php', 'disp_contacts' => '_threads.disp.php', 'disp_messages' => '_messages.disp.php', 'disp_page' => '_page.disp.php', 'disp_postidx' => '_postidx.disp.php', 'disp_posts' => '_posts.disp.php', 'disp_profile' => '_profile.disp.php', 'disp_avatar' => '_profile.disp.php', 'disp_pwdchange' => '_profile.disp.php', 'disp_userprefs' => '_profile.disp.php', 'disp_subs' => '_profile.disp.php', 'disp_search' => '_search.disp.php', 'disp_single' => '_single.disp.php', 'disp_sitemap' => '_sitemap.disp.php', 'disp_user' => '_user.disp.php', 'disp_users' => '_users.disp.php', 'disp_edit' => '_edit.disp.php', 'disp_edit_comment' => '_edit_comment.disp.php', 'disp_closeaccount' => '_closeaccount.disp.php', 'disp_module_form' => '_module_form.disp.php', 'disp_useritems' => '_useritems.disp.php', 'disp_usercomments' => '_usercomments.disp.php'); // Add plugin disp handlers: if ($disp_Plugins = $Plugins->get_list_by_event('GetHandledDispModes')) { foreach ($disp_Plugins as $disp_Plugin) { // Go through whole list of plugins providing disps if ($plugin_modes = $Plugins->call_method($disp_Plugin->ID, 'GetHandledDispModes', $disp_handlers)) { // plugin handles some custom disp modes foreach ($plugin_modes as $plugin_mode) { $disp_handlers[$plugin_mode] = '#' . $disp_Plugin->ID; } } } } // Allow skin overrides as well as additional disp modes (This can be used in the famou shopping cart scenario...) $disp_handlers = array_merge($disp_handlers, $params); if (!isset($disp_handlers['disp_' . $disp])) { global $Messages; $Messages->add(sprintf('Unhandled disp type [%s]', htmlspecialchars($disp))); $Messages->display(); $Timer->pause($timer_name); $disp = '404'; } $template_name = $disp_handlers['disp_' . $disp]; if (empty($template_name)) { // The caller asked not to display this handler $Timer->pause($timer_name); return; } } $disp_handled = false; if ($template_name[0] == '#') { // This disp mode is handled by a plugin: $plug_ID = substr($template_name, 1); $disp_params = array('disp' => $disp); $Plugins->call_method($plug_ID, 'HandleDispMode', $disp_params); $disp_handled = true; } elseif (file_exists($ads_current_skin_path . $template_name)) { // The skin has a customized handler, use that one instead: $file = $ads_current_skin_path . $template_name; $Debuglog->add('skin_include (' . ($Item ? 'Item #' . $Item->ID : '-') . '): ' . rel_path_to_base($file), 'skins'); require $file; $disp_handled = true; } elseif (file_exists($skins_path . $template_name)) { // Use the default template: global $Debuglog; $file = $skins_path . $template_name; $Debuglog->add('skin_include (' . ($Item ? 'Item #' . $Item->ID : '-') . '): ' . rel_path_to_base($file), 'skins'); require $file; $disp_handled = true; } if (!$disp_handled) { // nothing handled the disp mode printf('<div class="skin_error">Sub template [%s] not found.</div>', $template_name); if (!empty($current_User) && $current_User->level == 10) { printf('<div class="skin_error">User level 10 help info: [%s]</div>', $ads_current_skin_path . $template_name); } } $Timer->pause($timer_name); }
/** * Display paged list/table based on object parameters * * This is the meat of this class! * * @param array|NULL * @param array Fadeout settings array( 'key column' => array of values ) or 'session' * @return int # of rows displayed */ function display($display_params = NULL, $fadeout = NULL) { // Lazy fill $this->params: parent::display_init($display_params, $fadeout); // ------------------------- // Proceed with display: // ------------------------- echo $this->params['before']; if (!is_ajax_content()) { // Display TITLE/FILTERS only if NO AJAX request // DISPLAY TITLE: if (isset($this->title)) { // A title has been defined for this result set: echo $this->replace_vars($this->params['head_title']); } // Set this to TRUE in order to display all checkboxes before labels $this->force_checkboxes_to_inline = true; // DISPLAY FILTERS: $this->display_filters(); } // Flush in order to show the filters before slow SQL query will be executed below evo_flush(); // Initialize the order param $this->init_order_param(); // Make sure query has executed and we're at the top of the resultset: $this->restart(); if (!is_ajax_content()) { // Display COL SELECTION only if NO AJAX request $this->display_colselect(); } // START OF AJAX CONTENT: echo $this->replace_vars($this->params['content_start']); if ($this->total_pages == 0) { // There are no results! Nothing to display! // START OF LIST/TABLE: $this->display_list_start(); // END OF LIST/TABLE: $this->display_list_end(); } else { // We have rows to display: // Display internal messages $this->display_messages(); // GLOBAL (NAV) HEADER: $this->display_nav('header'); // START OF LIST/TABLE: $this->display_list_start(); // DISPLAY COLUMN HEADERS: $this->display_col_headers(); // GROUP & DATA ROWS: $this->display_body(); // Totals line $this->display_totals(); // Functions $this->display_functions(); // END OF LIST/TABLE: $this->display_list_end(); // GLOBAL (NAV) FOOTER: $this->display_nav('footer'); } // END OF AJAX CONTENT: echo $this->params['content_end']; echo $this->params['after']; // Return number of rows displayed: return $this->current_idx; }
/** * Display the edited items results table * * @param array Params */ function items_edited_results_block($params = array()) { // Make sure we are not missing any param: $params = array_merge(array('edited_User' => NULL, 'results_param_prefix' => 'actv_postedit_', 'results_title' => T_('Posts edited by the user'), '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', 'edit')) { // Check minimum permission: return; } $edited_User = $params['edited_User']; if (!$edited_User) { // No defined User, probably the function is calling from AJAX request $user_ID = param('user_ID', 'integer', 0); if (empty($user_ID)) { // Bad request, Exit here return; } $UserCache =& get_UserCache(); if (($edited_User =& $UserCache->get_by_ID($user_ID, false)) === false) { // Bad request, Exit here return; } } global $DB; param('user_tab', 'string', '', true); param('user_ID', 'integer', 0, true); $edited_versions_SQL = new SQL(); $edited_versions_SQL->SELECT('DISTINCT( iver_itm_ID )'); $edited_versions_SQL->FROM('T_items__version'); $edited_versions_SQL->WHERE('iver_edit_user_ID = ' . $DB->quote($edited_User->ID)); $SQL = new SQL(); $SQL->SELECT('*'); $SQL->FROM('T_items__item '); $SQL->WHERE('( ( post_lastedit_user_ID = ' . $DB->quote($edited_User->ID) . ' ) OR ( post_ID IN ( ' . $edited_versions_SQL->get() . ' ) ) )'); $SQL->WHERE_and('post_creator_user_ID != ' . $DB->quote($edited_User->ID)); // Create result set: $edited_items_Results = new Results($SQL->get(), $params['results_param_prefix'], 'D'); $edited_items_Results->Cache =& get_ItemCache(); $edited_items_Results->title = $params['results_title']; $edited_items_Results->no_results_text = $params['results_no_text']; // Get a count of the post which current user can delete $deleted_posts_edited_count = count($edited_User->get_deleted_posts('edited')); if ($edited_items_Results->total_rows > 0 && $deleted_posts_edited_count > 0) { // Display actino icon to delete all records if at least one record exists & current user can delete at least one item created by user $edited_items_Results->global_icon(sprintf(T_('Delete all post edited by %s'), $edited_User->login), 'delete', '?ctrl=user&user_tab=activity&action=delete_all_posts_edited&user_ID=' . $edited_User->ID . '&' . url_crumb('user'), ' ' . T_('Delete all'), 3, 4); } // Initialize Results object items_results($edited_items_Results, array('field_prefix' => 'post_', 'display_ord' => false, 'display_history' => false)); if (is_ajax_content()) { // init results param by template name if (!isset($params['skin_type']) || !isset($params['skin_name'])) { debug_die('Invalid ajax results request!'); } $edited_items_Results->init_params_by_skin($params['skin_type'], $params['skin_name']); } $display_params = array('before' => '<div class="results" style="margin-top:25px" id="edited_posts_result">'); $edited_items_Results->display($display_params); if (!is_ajax_content()) { // Create this hidden div to get a function name for AJAX request echo '<div id="' . $params['results_param_prefix'] . 'ajax_callback" style="display:none">' . __FUNCTION__ . '</div>'; } }
/** * Display user's reposts results table * * @param array Params */ function user_reports_results_block($params = array()) { // Make sure we are not missing any param: $params = array_merge(array('edited_User' => NULL, 'results_param_prefix' => 'actv_reports_', 'results_title' => T_('This user profile has been reported by other users!'), 'results_no_text' => T_('User was not reported yet.')), $params); if (!is_logged_in()) { // Only logged in users can access to this function return; } global $current_User; if (!$current_User->check_perm('users', 'edit')) { // Check minimum permission: return; } $edited_User = $params['edited_User']; if (!$edited_User) { // No defined User, probably the function is calling from AJAX request $user_ID = param('user_ID', 'integer', 0); if (empty($user_ID)) { // Bad request, Exit here return; } $UserCache =& get_UserCache(); if (($edited_User =& $UserCache->get_by_ID($user_ID, false)) === false) { // Bad request, Exit here return; } } global $DB; param('user_tab', 'string', '', true); param('user_ID', 'integer', 0, true); $SQL = new SQL(); $SQL->SELECT('user_login, urep_datetime, urep_status, urep_info'); $SQL->FROM('T_users__reports'); $SQL->FROM_add('LEFT JOIN T_users ON user_ID = urep_reporter_ID'); $SQL->WHERE('urep_target_user_ID = ' . $DB->quote($edited_User->ID)); // Create result set: $reports_Results = new Results($SQL->get(), $params['results_param_prefix'], 'D'); $reports_Results->title = $params['results_title']; $reports_Results->no_results_text = $params['results_no_text']; // Initialize Results object user_reports_results($reports_Results); if (is_ajax_content()) { // init results param by template name if (!isset($params['skin_type']) || !isset($params['skin_name'])) { debug_die('Invalid ajax results request!'); } $reports_Results->init_params_by_skin($params['skin_type'], $params['skin_name']); } $display_params = array('before' => '<div class="results" style="margin-top:25px" id="reports_result">'); $reports_Results->display($display_params); if (!is_ajax_content()) { // Create this hidden div to get a function name for AJAX request echo '<div id="' . $params['results_param_prefix'] . 'ajax_callback" style="display:none">' . __FUNCTION__ . '</div>'; } // Who should be able to delete other users reports??? /*if( $reports_Results->total_rows > 0 ) { // Display button to delete all records if at least one record exists & current user can delete at least one item created by user echo action_icon( sprintf( T_('Delete all reports from %s'), $edited_User->login ), 'delete', '?ctrl=user&user_tab=activity&action=delete_all_reports_from&user_ID='.$edited_User->ID.'&'.url_crumb('user'), ' '.T_('Delete all'), 3, 4 ); }*/ }
/** * Display all blogs results table * * @param array Params */ function blogs_all_results_block($params = array()) { // Make sure we are not missing any param: $params = array_merge(array('results_param_prefix' => 'blog_', 'results_title' => T_('List of Collections configured on this system') . get_manual_link('site-collection-list'), 'results_no_text' => T_('No blog has been created yet!'), 'results_no_perm_text' => T_('Sorry, you have no permission to edit/view any blog\'s properties.')), $params); if (!is_logged_in()) { // Only logged in users can access to this function return; } global $current_User; if (is_ajax_content()) { $order_action = param('order_action', 'string'); if ($order_action == 'update') { // Update an order to new value $new_value = (int) param('new_value', 'string', 0); $order_data = param('order_data', 'string'); $order_obj_ID = (int) str_replace('order-blog-', '', $order_data); if ($order_obj_ID > 0) { // Update blog order $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)) { // Check permission to edit this Blog $updated_Blog->set('order', $new_value); $updated_Blog->dbupdate(); $BlogCache->clear(); } } } } } $SQL = new SQL(); $SQL->SELECT('T_blogs.*, user_login'); $SQL->FROM('T_blogs INNER JOIN T_users ON blog_owner_user_ID = user_ID'); if (!$current_User->check_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 . ' )' . ' LEFT JOIN T_coll_group_perms ON (blog_advanced_perms <> 0' . ' AND blog_ID = bloggroup_blog_ID' . ' AND bloggroup_group_ID = ' . $current_User->grp_ID . ' )'); $SQL->WHERE('blog_owner_user_ID = ' . $current_User->ID . ' OR bloguser_ismember <> 0' . ' OR bloggroup_ismember <> 0'); $no_results = $params['results_no_perm_text']; } else { $no_results = $params['results_no_text']; } // Create result set: $blogs_Results = new Results($SQL->get(), $params['results_param_prefix'], '---------A'); $blogs_Results->Cache =& get_BlogCache(); $blogs_Results->title = $params['results_title']; $blogs_Results->no_results_text = $no_results; if ($current_User->check_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')); } // Initialize Results object blogs_results($blogs_Results); if (is_ajax_content()) { // init results param by template name if (!isset($params['skin_type']) || !isset($params['skin_name'])) { debug_die('Invalid ajax results request!'); } $blogs_Results->init_params_by_skin($params['skin_type'], $params['skin_name']); } $blogs_Results->display(NULL, 'session'); if (!is_ajax_content()) { // Create this hidden div to get a function name for AJAX request echo '<div id="' . $params['results_param_prefix'] . 'ajax_callback" style="display:none">' . __FUNCTION__ . '</div>'; } }
/** * Display list/table head. * * This includes list head/title and filters. * EXPERIMENTAL: also dispays <tfoot> */ function display_head() { if (is_ajax_content()) { // Don't display this content on AJAX request return; } // DISPLAY TITLE: if (isset($this->title)) { // A title has been defined for this result set: echo $this->replace_vars($this->params['head_title']); } // DISPLAY FILTERS: $this->display_filters(); // DISPLAY COL SELECTION $this->display_colselect(); // Experimental: /*echo $this->params['tfoot_start']; echo $this->params['tfoot_end'];*/ }
/** * Display hits results table */ function hits_results_block($params = array()) { if (!is_logged_in()) { // Only logged in users can access to this function return; } global $current_User; if (!$current_User->check_perm('stats', 'view')) { // Current user has no permission to view all stats (aggregated stats) return; } /** * View funcs */ load_funcs('sessions/views/_stats_view.funcs.php'); global $blog, $admin_url, $rsc_url; global $Session, $UserSettings, $DB; global $datestartinput, $datestart, $datestopinput, $datestop; global $preset_referer_type, $preset_agent_type; $tab = param('tab', 'string', 'summary', true); $tab3 = param('tab3', 'string', '', true); switch ($tab) { case 'other': $preset_results_title = T_('Direct browser hits'); $preset_referer_type = 'direct'; $preset_agent_type = 'browser'; $preset_filter_all_url = '?ctrl=stats&tab=referers&blog=' . $blog; $hide_columns = 'referer'; break; case 'referers': $preset_results_title = T_('Refered browser hits'); $preset_referer_type = 'referer'; $preset_agent_type = 'browser'; $preset_filter_all_url = '?ctrl=stats&tab=referers&blog=' . $blog; break; case 'refsearches': if ($tab3 == 'hits') { $preset_results_title = T_('Search hits'); $preset_referer_type = 'search'; $preset_agent_type = 'browser'; $preset_filter_all_url = '?ctrl=stats&tab=refsearches&tab3=hits&blog=' . $blog; } break; } if (param_date('datestartinput', T_('Invalid date'), false, NULL) !== NULL) { // We have a user provided localized date: memorize_param('datestart', 'string', NULL, trim(form_date($datestartinput))); } else { // We may have an automated param transmission date: param('datestart', 'string', '', true); } if (param_date('datestopinput', T_('Invalid date'), false, NULL) !== NULL) { // We have a user provided localized date: memorize_param('datestop', 'string', NULL, trim(form_date($datestopinput))); } else { // We may have an automated param transmission date: param('datestop', 'string', '', true); } $exclude = param('exclude', 'integer', 0, true); $sess_ID = param('sess_ID', 'integer', NULL, true); $remote_IP = param('remote_IP', 'string', NULL, true); $referer_type = isset($preset_referer_type) ? $preset_referer_type : param('referer_type', 'string', NULL, true); $agent_type = isset($preset_agent_type) ? $preset_agent_type : param('agent_type', 'string', NULL, true); $device = param('device', 'string', NULL, true); $hit_type = param('hit_type', 'string', NULL, true); $reqURI = param('reqURI', 'string', NULL, true); // Create result set: $SQL = new SQL(); $SQL->SELECT('SQL_NO_CACHE hit_ID, sess_ID, sess_device, hit_datetime, hit_type, hit_referer_type, hit_uri, hit_disp, hit_ctrl, hit_action, hit_blog_ID, hit_referer, hit_remote_addr,' . 'user_login, hit_agent_type, blog_shortname, dom_name, goal_name, hit_keyphrase, hit_serprank, hit_response_code'); $SQL->FROM('T_hitlog LEFT JOIN T_basedomains ON dom_ID = hit_referer_dom_ID' . ' LEFT JOIN T_sessions ON hit_sess_ID = sess_ID' . ' LEFT JOIN T_blogs ON hit_blog_ID = blog_ID' . ' LEFT JOIN T_users ON sess_user_ID = user_ID' . ' LEFT JOIN T_track__goalhit ON hit_ID = ghit_hit_ID' . ' LEFT JOIN T_track__goal ON ghit_goal_ID = goal_ID'); $CountSQL = new SQL(); $CountSQL->SELECT('SQL_NO_CACHE COUNT(hit_ID)'); $CountSQL->FROM('T_hitlog'); $operator = $exclude ? ' <> ' : ' = '; if (!empty($sess_ID)) { // We want to filter on the session ID: $filter = 'hit_sess_ID' . $operator . $sess_ID; $SQL->WHERE($filter); $CountSQL->WHERE($filter); } elseif (!empty($remote_IP)) { // We want to filter on the goal name: $filter = 'hit_remote_addr' . $operator . $DB->quote($remote_IP); $SQL->WHERE($filter); $CountSQL->WHERE($filter); } if (!empty($referer_type)) { $filter = 'hit_referer_type = ' . $DB->quote($referer_type); $SQL->WHERE_and($filter); $CountSQL->WHERE_and($filter); } if (!empty($agent_type)) { $filter = 'hit_agent_type = ' . $DB->quote($agent_type); $SQL->WHERE_and($filter); $CountSQL->WHERE_and($filter); } if (!empty($device)) { if ($device == 'other') { // Unknown device $device = ''; } $filter = 'sess_device = ' . $DB->quote($device); $SQL->WHERE_and($filter); $CountSQL->WHERE_and($filter); $CountSQL->FROM_add('LEFT JOIN T_sessions ON hit_sess_ID = sess_ID'); } if (!empty($hit_type)) { $filter = 'hit_type = ' . $DB->quote($hit_type); $SQL->WHERE_and($filter); $CountSQL->WHERE_and($filter); } if (!empty($reqURI)) { $filter = 'hit_uri LIKE ' . $DB->quote($reqURI); $SQL->WHERE_and($filter); $CountSQL->WHERE_and($filter); } if (!empty($datestart)) { $SQL->WHERE_and('hit_datetime >= ' . $DB->quote($datestart . ' 00:00:00')); $CountSQL->WHERE_and('hit_datetime >= ' . $DB->quote($datestart . ' 00:00:00')); } if (!empty($datestop)) { $SQL->WHERE_and('hit_datetime <= ' . $DB->quote($datestop . ' 23:59:59')); $CountSQL->WHERE_and('hit_datetime <= ' . $DB->quote($datestop . ' 23:59:59')); } if (!empty($blog)) { $filter = 'hit_blog_ID = ' . $DB->escape($blog); $SQL->WHERE_and($filter); $CountSQL->WHERE_and($filter); } $resuts_param_prefix = 'hits_'; if (!empty($preset_referer_type)) { $resuts_param_prefix = substr($preset_referer_type, 0, 8) . '_' . $resuts_param_prefix; } $Results = new Results($SQL->get(), $resuts_param_prefix, '--D', $UserSettings->get('results_per_page'), $CountSQL->get()); // Initialize Results object hits_results($Results); if (is_ajax_content()) { // init results param by template name if (!isset($params['skin_type']) || !isset($params['skin_name'])) { debug_die('Invalid ajax results request!'); } $Results->init_params_by_skin($params['skin_type'], $params['skin_name']); } // Display results: $Results->display(); if (!is_ajax_content()) { // Create this hidden div to get a function name for AJAX request echo '<div id="' . $resuts_param_prefix . 'ajax_callback" style="display:none">' . __FUNCTION__ . '</div>'; } }
/** * Display comments results table * * @param array Params */ function comments_results_block($params = array()) { // Make sure we are not missing any param: $params = array_merge(array('edited_User' => NULL, 'results_param_prefix' => 'actv_comment_', 'results_title' => T_('Comments posted by the user'), 'results_no_text' => T_('User has not posted any comment yet')), $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')) { // Check minimum permission: return; } $edited_User = $params['edited_User']; if (!$edited_User) { // No defined User, probably the function is calling from AJAX request $user_ID = param('user_ID', 'integer', 0); if (empty($user_ID)) { // Bad request, Exit here return; } $UserCache =& get_UserCache(); if (($edited_User =& $UserCache->get_by_ID($user_ID, false)) === false) { // Bad request, Exit here return; } } global $DB, $AdminUI; param('user_tab', 'string', '', true); param('user_ID', 'integer', 0, true); $SQL = new SQL(); $SQL->SELECT('*'); $SQL->FROM('T_comments'); $SQL->WHERE('comment_author_user_ID = ' . $DB->quote($edited_User->ID)); // Create result set: $comments_Results = new Results($SQL->get(), $params['results_param_prefix'], 'D'); $comments_Results->Cache =& get_CommentCache(); $comments_Results->title = $params['results_title']; $comments_Results->no_results_text = $params['results_no_text']; if ($comments_Results->get_total_rows() > 0 && $edited_User->has_comment_to_delete()) { // Display action icon to delete all records if at least one record exists & current user can delete at least one comment posted by user $comments_Results->global_icon(sprintf(T_('Delete all comments posted by %s'), $edited_User->login), 'recycle', '?ctrl=user&user_tab=activity&action=delete_all_comments&user_ID=' . $edited_User->ID . '&' . url_crumb('user'), ' ' . T_('Delete all'), 3, 4); } // Initialize Results object comments_results($comments_Results, array('field_prefix' => 'comment_', 'display_kind' => false, 'display_additional_columns' => true, 'plugin_table_name' => 'activity', 'display_spam' => false)); if (is_ajax_content()) { // init results param by template name if (!isset($params['skin_type']) || !isset($params['skin_name'])) { debug_die('Invalid ajax results request!'); } $comments_Results->init_params_by_skin($params['skin_type'], $params['skin_name']); } $results_params = $AdminUI->get_template('Results'); $display_params = array('before' => str_replace('>', ' style="margin-top:25px" id="comments_result">', $results_params['before'])); $comments_Results->display($display_params); if (!is_ajax_content()) { // Create this hidden div to get a function name for AJAX request echo '<div id="' . $params['results_param_prefix'] . 'ajax_callback" style="display:none">' . __FUNCTION__ . '</div>'; } }