Ejemplo n.º 1
0
function contacts_groups($user_ID)
{
    global $current_User, $DB, $cache_user_contacts_groups;
    if (!is_array($cache_user_contacts_groups)) {
        // Execute only first time to init cache
        $cache_user_contacts_groups = array();
        // Get contacts of current user
        $groups_SQL = new SQL();
        $groups_SQL->SELECT('cgr_ID AS ID, cgu_user_ID AS user_ID, cgr_name AS name');
        $groups_SQL->FROM('T_messaging__contact_groupusers');
        $groups_SQL->FROM_add('LEFT JOIN T_messaging__contact_groups ON cgu_cgr_ID = cgr_ID');
        $groups_SQL->WHERE('cgr_user_ID = ' . $current_User->ID);
        $groups_SQL->ORDER_BY('cgr_name');
        $groups = $DB->get_results($groups_SQL->get());
        $remove_link = url_add_param(get_dispctrl_url('contacts'), 'action=remove_user&view=contacts&' . url_crumb('messaging_contacts'));
        foreach ($groups as $group) {
            // Init cache for groups for each contact of current user
            $group_name = $group->name . action_icon(T_('Remove user from this group'), 'remove', url_add_param($remove_link, 'user_ID=' . $group->user_ID . '&group_ID=' . $group->ID));
            if (isset($cache_user_contacts_groups[$group->user_ID])) {
                // nth group of this user
                $cache_user_contacts_groups[$group->user_ID] .= '<br />' . $group_name;
            } else {
                // first group of this user
                $cache_user_contacts_groups[$group->user_ID] = $group_name;
            }
        }
    }
    if (isset($cache_user_contacts_groups[$user_ID])) {
        // user has groups
        echo $cache_user_contacts_groups[$user_ID];
    }
}
Ejemplo n.º 2
0
 /**
  * Get link to back users list
  *
  * @return string Link to back users list
  */
 function back_user_link($before = '', $after = '', $display = true)
 {
     // ID of selected user
     $user_ID = get_param('user_ID');
     $users_list = $this->filters['users'];
     $user_key = array_search($user_ID, $users_list);
     if (is_int($user_key)) {
         // Selected user is located in this list
         global $Blog;
         ++$user_key;
         $page = ceil($user_key / $this->limit);
         $page_param = '';
         if ($page > 1) {
             $page_param = $this->page_param . '=' . $page;
         }
         $output = $before;
         $output .= '<a href="' . get_dispctrl_url('users', $page_param) . '">' . $user_key . '/' . count($users_list) . '</a>';
         $output .= $after;
     } else {
         $output = '';
     }
     if ($display) {
         echo $output;
     }
     return $output;
 }
Ejemplo n.º 3
0
    die('Please, do not access this page directly.');
}
/**
 * @var Organization
 */
global $edited_Organization;
// Determine if we are creating or updating...
global $action;
$creating = is_create_action($action);
$Form = new Form(NULL, 'organization_checkchanges', 'post', 'compact');
if (!$creating) {
    $Form->global_icon(T_('Delete this organization!'), 'delete', regenerate_url('action', 'action=delete&amp;' . url_crumb('organization')));
}
$Form->global_icon(T_('Cancel editing!'), 'close', regenerate_url('action,org_ID'));
$Form->begin_form('fform', ($creating ? T_('New organization') : T_('Organization')) . get_manual_link('organization-form'));
$Form->add_crumb('organization');
$Form->hiddens_by_key(get_memorized('action'));
// (this allows to come back to the right list order & page)
$Form->text_input('org_name', $edited_Organization->name, 32, T_('Name'), '', array('maxlength' => 255, 'required' => true));
$Form->text_input('org_url', $edited_Organization->url, 32, T_('Url'), '', array('maxlength' => 2000));
if ($creating) {
    $Form->end_form(array(array('submit', 'actionArray[create]', T_('Record'), 'SaveButton'), array('submit', 'actionArray[create_new]', T_('Record, then Create New'), 'SaveButton'), array('submit', 'actionArray[create_copy]', T_('Record, then Create Similar'), 'SaveButton')));
} else {
    $Form->end_form(array(array('submit', 'actionArray[update]', T_('Save Changes!'), 'SaveButton')));
}
if ($edited_Organization->ID > 0) {
    // Display users of this organization
    users_results_block(array('org_ID' => $edited_Organization->ID, 'filterset_name' => 'orgusr_' . $edited_Organization->ID, 'results_param_prefix' => 'orgusr_', 'results_title' => T_('Users of this organization') . get_manual_link('users_and_groups'), 'results_order' => '/uorg_accepted/D', 'page_url' => get_dispctrl_url('organizations', 'action=edit&amp;org_ID=' . $edited_Organization->ID), 'display_orgstatus' => true, 'display_ID' => false, 'display_btn_adduser' => false, 'display_btn_addgroup' => false, 'display_blogs' => false, 'display_source' => false, 'display_regdate' => false, 'display_regcountry' => false, 'display_update' => false, 'display_lastvisit' => false, 'display_contact' => false, 'display_reported' => false, 'display_group' => false, 'display_level' => false, 'display_status' => false, 'display_actions' => false, 'display_newsletter' => false));
}
// AJAX changing of an accept status of organizations for each user
echo_user_organization_js();
Ejemplo n.º 4
0
    $UserList->cols[] = array('th' => T_('Actions'), 'th_class' => 'small', 'td_class' => 'shrinkwrap small', 'td' => action_icon(T_('Edit this user...'), 'edit', '%regenerate_url( \'ctrl,action\', \'ctrl=user&amp;user_ID=$user_ID$&amp;user_tab=profile\' )%') . action_icon(T_('Duplicate this user...'), 'copy', '%regenerate_url( \'ctrl,action\', \'ctrl=user&amp;action=new&amp;user_ID=$user_ID$&amp;user_tab=profile\' )%') . '~conditional( (#user_ID# != 1) && (#user_ID# != ' . $current_User->ID . '), \'' . action_icon(T_('Delete this user!'), 'delete', '%regenerate_url( \'action\', \'action=delete&amp;user_ID=$user_ID$&amp;' . url_crumb('user') . '\' )%') . '\', \'' . get_icon('delete', 'noimg') . '\' )~');
}
if ($action == 'show_recent') {
    // Sort an users list by "Registered" field
    $UserList->set_order('user_created_datetime');
}
// Execute query
$UserList->query();
$filter_presets = array('all' => array(T_('All users'), get_dispctrl_url('users&amp;filter=new')), 'men' => array(T_('Men'), get_dispctrl_url('users', 'gender_men=1&amp;filter=new')), 'women' => array(T_('Women'), get_dispctrl_url('users', 'gender_women=1&amp;filter=new')));
if (is_admin_page()) {
    // Add show only activated users filter only on admin interface
    $filter_presets['activated'] = array(T_('Activated users'), get_dispctrl_url('users', 'status_activated=1&amp;filter=new'));
    if ($current_User->check_perm('users', 'edit')) {
        // Show "Reported Users" filter only for users with edit user permission
        $filter_presets['reported'] = array(T_('Reported users'), get_dispctrl_url('users', 'reported=1&amp;filter=new'));
    }
}
if ($UserList->is_filtered()) {
    // Display link to reset filters only if some filter is applied
    $filter_presets['reset'] = array(T_('Reset Filters'), get_dispctrl_url('users&amp;filter=reset'), 'class="floatright"');
}
$UserList->filter_area = array('callback' => 'callback_filter_userlist', 'url_ignore' => 'users_paged,u_paged,keywords', 'presets' => $filter_presets);
// Display result :
$UserList->display($display_params);
if ($current_User->check_perm('users', 'edit') && $UserList->result_num_rows > 0) {
    // Newsletter button
    echo '<p class="center">';
    echo '<input type="button" value="' . T_('Send newsletter to the current selection') . '" onclick="location.href=\'' . $admin_url . '?ctrl=newsletter\'" />';
    echo '</p>';
}
load_funcs('users/model/_user_js.funcs.php');
Ejemplo n.º 5
0
 /**
  * Get contacts list params
  */
 function get_contacts_list_params()
 {
     global $module_contacts_list_params;
     if (!isset($module_contacts_list_params)) {
         // Initialize this array first time
         $module_contacts_list_params = array();
     }
     $module_contacts_list_params['title_selected'] = T_('Send a message to all selected contacts');
     $module_contacts_list_params['title_group'] = T_('Send a message to all %d contacts in the &laquo;%s&raquo; group');
     $module_contacts_list_params['recipients_link'] = get_dispctrl_url('threads', 'action=new');
 }
Ejemplo n.º 6
0
}
if ($unread_messages_count > 0 && !$perm_abuse_management) {
    $Results->title = $Results->title . ' <span class="badge">' . $unread_messages_count . '</span></b>';
}
/**
 * Callback to add filters on top of the result set
 *
 * @param Form
 */
function filter_recipients(&$Form)
{
    global $perm_abuse_management;
    $Form->text('s', get_param('s'), 20, T_('Search'), '', 255);
    $Form->text('u', get_param('u'), 10, T_('User'), '', 255);
    if (!$perm_abuse_management) {
        $Form->checkbox('show_closed', get_param('show_closed'), T_('Show closed conversations'));
    }
}
$Results->filter_area = array('callback' => 'filter_recipients', 'presets' => array('all' => array(T_('All'), get_dispctrl_url($perm_abuse_management ? 'abuse' : 'threads'))));
// Initialize Results object
threads_results($Results, array_merge(array('abuse_management' => (int) $perm_abuse_management), $display_params));
if (!$perm_abuse_management) {
    // Show link to create a new conversation
    if (is_admin_page()) {
        $newmsg_url = regenerate_url('action', 'action=new');
    } else {
        $newmsg_url = regenerate_url('disp', 'disp=threads&action=new');
    }
    $Results->global_icon(T_('Create a new conversation...'), 'new', $newmsg_url, T_('Compose new') . ' &raquo;', 3, 4);
}
$Results->display($display_params);
Ejemplo n.º 7
0
/**
 * Get action icons to delete thread
 *
 * @param integer Thread ID
 * @return string Action icon
 */
function col_thread_delete_action($thread_ID)
{
    global $Blog, $samedomain_htsrv_url, $admin_url;
    if (is_admin_page()) {
        $redirect_to = rawurlencode(regenerate_url('', '', '', '&'));
        return action_icon(T_('Delete'), 'delete', $admin_url . '?ctrl=threads&amp;thrd_ID=' . $thread_ID . '&amp;action=delete&amp;' . url_crumb('messaging_threads') . '&amp;redirect_to=' . $redirect_to);
    } else {
        $redirect_to = get_dispctrl_url('threads');
        return action_icon(T_('Delete'), 'delete', $samedomain_htsrv_url . 'action.php?mname=messaging&thrd_ID=' . $thread_ID . '&action=delete&redirect_to=' . $redirect_to . '&' . url_crumb('messaging_threads'));
    }
}
Ejemplo n.º 8
0
 /**
  * Get number of comments and percent of published comments and number of helpful votes on comments by this user
  *
  * @param array Params
  * @return string Result
  */
 function get_reputation_comments($params = array())
 {
     // Make sure we are not missing any param:
     $params = array_merge(array('view_type' => 'simple', 'text_simple' => T_('%s has posted %s comments (%s%% of which are public). %s of these comments have been found useful by %s different users.'), 'text_extended' => T_('%s has posted %s comments (%s%% of which are public).<br />%s voted useful by %s different users.<br />%s voted NOT useful by %s different users.<br />%s considered OK by %s different users.<br />%s considered SPAM by %s different users.')), $params);
     $total_num_comments = $this->get_num_comments();
     $public_num_comments = $this->get_num_comments('published');
     if ($total_num_comments > 0) {
         // Calc percent of published comments
         $public_percent = floor($public_num_comments / $total_num_comments * 100);
     } else {
         // To avoid devision by zero
         $public_percent = 0;
     }
     if ($total_num_comments > 0) {
         // Make a link to page with user's comments
         $total_num_comments = '<a href="' . get_dispctrl_url('usercomments', 'user_ID=' . $this->ID) . '"><b>' . $total_num_comments . '</b></a>';
     } else {
         $total_num_comments = '<b>' . $total_num_comments . '</b>';
     }
     // Get number of helpful votes on comments for this user
     global $DB;
     $comments_SQL = new SQL();
     if ($params['view_type'] == 'simple') {
         // Simple view
         $comments_SQL->SELECT('cmvt_user_ID AS user_ID, COUNT(*) AS cnt');
     } else {
         // Extended view
         $comments_SQL->SELECT('cmvt_user_ID AS user_ID, cmvt_helpful, cmvt_spam');
     }
     $comments_SQL->FROM('T_comments');
     $comments_SQL->FROM_add('INNER JOIN T_comments__votes ON comment_ID = cmvt_cmt_ID');
     $comments_SQL->WHERE('comment_author_user_ID = ' . $this->ID);
     $comments_SQL->WHERE_and('comment_status IN ( "published", "community", "protected", "review" )');
     if ($params['view_type'] == 'simple') {
         // Simple view
         $comments_SQL->WHERE_and('cmvt_helpful = 1');
         $comments_SQL->GROUP_BY('user_ID');
     }
     if ($params['view_type'] == 'simple') {
         // Simple view
         $votes = $DB->get_assoc($comments_SQL->get());
         // Calculate total votes from all users
         $users_count_useful = count($votes);
         $votes_count_useful = 0;
         foreach ($votes as $user_votes) {
             $votes_count_useful += $user_votes;
         }
         return sprintf($params['text_simple'], $this->login, $total_num_comments, $public_percent, '<b class="green">' . $votes_count_useful . '</b>', '<b>' . $users_count_useful . '</b>');
     } else {
         // Extended view
         $votes = $DB->get_results($comments_SQL->get());
         $votes_count_useful = 0;
         $users_count_useful = array();
         $votes_count_not = 0;
         $users_count_not = array();
         $votes_count_ok = 0;
         $users_count_ok = array();
         $votes_count_spam = 0;
         $users_count_spam = array();
         foreach ($votes as $vote) {
             if ($vote->cmvt_helpful === '1') {
                 // Useful votes
                 $votes_count_useful++;
                 $users_count_useful[$vote->user_ID] = NULL;
             } elseif ($vote->cmvt_helpful === '-1') {
                 // Not useful votes
                 $votes_count_not++;
                 $users_count_not[$vote->user_ID] = NULL;
             }
             if ($vote->cmvt_spam === '-1') {
                 // Ok votes
                 $votes_count_ok++;
                 $users_count_ok[$vote->user_ID] = NULL;
             } elseif ($vote->cmvt_spam === '1') {
                 // Spam votes
                 $votes_count_spam++;
                 $users_count_spam[$vote->user_ID] = NULL;
             }
         }
         return sprintf($params['text_extended'], $this->login, $total_num_comments, $public_percent, '<b class="green">' . $votes_count_useful . '</b>', '<b>' . count($users_count_useful) . '</b>', '<b class="red">' . $votes_count_not . '</b>', '<b>' . count($users_count_not) . '</b>', '<b class="green">' . $votes_count_ok . '</b>', '<b>' . count($users_count_ok) . '</b>', '<b class="red">' . $votes_count_spam . '</b>', '<b>' . count($users_count_spam) . '</b>');
     }
 }
Ejemplo n.º 9
0
 * @version $Id: comments.main.php 3157 2013-03-06 04:34:44Z fplanque $
 */
if (!defined('EVO_MAIN_INIT')) {
    die('Please, do not access this page directly.');
}
// What level of detail do we want?
$feed_content = $Blog->get_setting('comment_feed_content');
if ($feed_content == 'none') {
    // We don't want to provide this feed!
    // This will normaly have been detected earlier but just for security:
    debug_die('Feeds are disabled.');
}
if (!$Blog->get_setting('comments_latest')) {
    // The latest comments are disabled for current blog
    // Redirect to page with text/html mime type
    header_redirect(get_dispctrl_url('comments'), 302);
    // will have exited
}
if (isset($Item)) {
    // Comments for a specific Item:
    $post_ID = $Item->ID;
    $selfurl = format_to_output($Item->get_feedback_feed_url('_rss2'), 'xmlattr');
} else {
    // Comments for the blog:
    $post_ID = NULL;
    $selfurl = format_to_output($Blog->get_comment_feed_url('_rss2'), 'xmlattr');
}
$CommentList = new CommentList2($Blog);
// Filter list:
$CommentList->set_filters(array('types' => array('comment'), 'statuses' => array('published'), 'post_ID' => $post_ID, 'order' => 'DESC', 'comments' => $Blog->get_setting('comments_per_feed')));
// Get ready for display (runs the query):
Ejemplo n.º 10
0
$Results = new Results($select_SQL->get(), 'msg_', '', 0, $count_SQL->get());
$Results->Cache =& get_MessageCache();
$Results->title = $params['messages_list_title'];
if (is_admin_page()) {
    $Results->global_icon(T_('Cancel!'), 'close', '?ctrl=threads');
}
/**
 * Callback to add filters on top of the result set
 *
 * @param Form
 */
function filter_messages(&$Form)
{
    $Form->text('s', get_param('s'), 30, T_('Search'), '', 255);
}
$Results->filter_area = array('submit_title' => T_('Filter messages'), 'callback' => 'filter_messages', 'presets' => array('all' => array(T_('All'), get_dispctrl_url('messages', 'thrd_ID=' . $edited_Thread->ID))));
/*
 * Author col:
 */
/**
 * Create author cell for message list table
 *
 * @param integer user ID
 * @param string login
 * @param string first name
 * @param string last name
 * @param integer avatar ID
 * @param string datetime
 */
function author($user_ID, $datetime)
{
Ejemplo n.º 11
0
/**
 * Get URL to user contacts
 */
function get_user_contacts_url()
{
    global $current_User, $Blog;
    if (!is_logged_in()) {
        return false;
    }
    return get_dispctrl_url('contacts');
}
Ejemplo n.º 12
0
 /**
  * Display the widget!
  *
  * @param array MUST contain at least the basic display params
  */
 function display($params)
 {
     /**
      * @var Blog
      */
     global $Blog;
     global $current_User, $unread_messages_count;
     global $disp;
     $this->init_display($params);
     switch ($this->disp_params['show_to']) {
         case 'any':
             break;
         case 'loggedin':
             if (!is_logged_in()) {
                 return false;
             }
             break;
         case 'perms':
             if (!is_logged_in() || !$current_User->check_perm('perm_messaging', 'reply', false)) {
                 return false;
             }
             break;
             // display
         // display
         case 'default':
             debug_die('Invalid params!');
     }
     // Default link class
     $link_class = $this->disp_params['link_default_class'];
     switch ($this->disp_params['link_type']) {
         case 'messages':
             $url = get_dispctrl_url('threads');
             $text = T_('Messages');
             // Is this the current display?
             if ($disp == 'threads') {
                 // The current page is currently displaying the messages:
                 // Let's display it as selected
                 $link_class = $this->disp_params['link_selected_class'];
             }
             break;
         case 'contacts':
             $url = get_dispctrl_url('contacts');
             $text = T_('Contacts');
             // set show badge to 0, this way make sure badge won't be displayed
             $this->disp_params['show_badge'] = 0;
             // Is this the current display?
             if ($disp == 'contacts') {
                 // The current page is currently displaying the contacts:
                 // Let's display it as selected
                 $link_class = $this->disp_params['link_selected_class'];
             }
             break;
     }
     if (!empty($this->disp_params['link_text'])) {
         $text = $this->disp_params['link_text'];
     }
     if ($this->disp_params['show_badge'] && $unread_messages_count > 0) {
         $badge = ' <span class="badge">' . $unread_messages_count . '</span>';
     } else {
         $badge = '';
     }
     echo $this->disp_params['block_start'];
     echo $this->disp_params['list_start'];
     echo $this->disp_params['item_start'];
     echo '<a href="' . $url . '" class="' . $link_class . '">' . $text . $badge . '</a>';
     echo $this->disp_params['item_end'];
     echo $this->disp_params['list_end'];
     echo $this->disp_params['block_end'];
     return true;
 }
Ejemplo n.º 13
0
 /**
  * Get number of comments and percent of published comments by this user
  *
  * @param array Params
  * @return string Result
  */
 function get_reputation_comments($params = array())
 {
     // Make sure we are not missing any param:
     $params = array_merge(array('text' => T_('%s (%s%% are public)')), $params);
     $total_num_comments = $this->get_num_comments();
     $public_num_comments = $this->get_num_comments('published');
     if ($total_num_comments > 0) {
         // Calc percent of published comments
         $public_percent = floor($public_num_comments / $total_num_comments * 100);
     } else {
         // To avoid devision by zero
         $public_percent = 0;
     }
     if ($total_num_comments > 0) {
         // Make a link to page with user's comments
         $total_num_comments = '<a href="' . get_dispctrl_url('usercomments&amp;user_ID=' . $this->ID) . '"><b>' . $total_num_comments . '</b></a>';
     } else {
         $total_num_comments = '<b>' . $total_num_comments . '</b>';
     }
     return sprintf($params['text'], $total_num_comments, $public_percent);
 }
Ejemplo n.º 14
0
}
/**
 * Callback to add filters on top of the result set
 *
 * @param Form
 */
function filter_recipients(&$Form)
{
    global $perm_abuse_management;
    $Form->text('s', get_param('s'), 20, T_('Search'), '', 255);
    $Form->text('u', get_param('u'), 10, T_('User'), '', 255);
    if (!$perm_abuse_management) {
        $Form->checkbox('show_closed', get_param('show_closed'), T_('Show closed conversations'));
    }
}
if ($perm_abuse_management) {
    // In case of abuse management
    $preset_filters = array('all' => array(T_('All'), get_dispctrl_url('abuse')));
} else {
    // In case of simple thread list view
    $preset_filters = array('avtive' => array(T_('Active conversations'), get_dispctrl_url('threads', 'show_closed=0')), 'all' => array(T_('All conversations'), get_dispctrl_url('threads', 'show_closed=1')));
}
$Results->filter_area = array('callback' => 'filter_recipients', 'presets' => $preset_filters);
// Initialize Results object
threads_results($Results, array_merge(array('abuse_management' => (int) $perm_abuse_management), $display_params));
if (!$perm_abuse_management) {
    // Show link to create a new conversation
    $Results->global_icon(T_('See My Contacts'), 'contacts', get_dispctrl_url('contacts'), T_('See My Contacts') . ' ', 3, 4);
    $Results->global_icon(T_('Create a new conversation...'), 'compose_new', get_dispctrl_url('threads', 'action=new'), T_('Compose new') . ' &raquo;', 3, 4, array('class' => 'action_icon btn-primary'));
}
$Results->display($display_params);
Ejemplo n.º 15
0
// ------------------------- END OF PREV/NEXT USER LINKS -------------------------
$user_ID = param('user_ID', 'integer', '');
if (empty($user_ID)) {
    // Grab the current User
    $user_ID = $current_User->ID;
}
$UserCache =& get_UserCache();
/**
 * @var User
 */
$User =& $UserCache->get_by_ID($user_ID);
/**
 * form to update the profile
 * @var Form
 */
$ProfileForm = new Form(get_dispctrl_url('contacts'), 'ProfileForm');
$ProfileForm->switch_template_parts($params['skin_form_params']);
if ($is_logged_in) {
    // user is logged in
    if ($current_User->check_perm('users', 'edit') && $current_User->check_status('can_access_admin')) {
        // Current user can edit other user's profiles
        global $admin_url;
        echo '<div class="edit_user_admin_link">';
        echo '<a href="' . url_add_param($admin_url, 'ctrl=user&amp;user_ID=' . $User->ID) . '">' . $params['edit_user_admin_link_text'] . '</a>';
        echo '</div>';
    }
    if ($User->ID == $current_User->ID && !empty($params['edit_my_profile_link_text'])) {
        // Display edit link profile for owner:
        echo '<div class="floatright">';
        echo '<a href="' . url_add_param($Blog->get('url'), 'disp=profile') . '">' . $params['edit_my_profile_link_text'] . '</a>';
        echo '</div>';
Ejemplo n.º 16
0
/**
 * Display the users results table
 *
 * @param array Params
 */
function users_results_block($params = array())
{
    // Make sure we are not missing any param:
    $params = array_merge(array('org_ID' => NULL, 'filterset_name' => 'admin', 'results_param_prefix' => 'users_', 'results_title' => T_('Users') . get_manual_link('users_and_groups'), 'results_no_text' => T_('No users'), 'results_order' => '/user_lastseen_ts/D', 'page_url' => get_dispctrl_url('users'), 'join_group' => true, 'join_city' => false, 'join_country' => true, 'keywords_fields' => NULL, 'where_status_closed' => NULL, 'display_params' => array(), 'display_orgstatus' => false, 'display_filters' => true, 'display_btn_refresh' => true, 'display_btn_adduser' => true, 'display_btn_addgroup' => true, 'display_ID' => true, 'display_avatar' => true, 'display_login' => true, 'display_nickname' => true, 'display_name' => true, 'display_gender' => true, 'display_country' => true, 'display_city' => false, 'display_blogs' => true, 'display_source' => true, 'display_regdate' => true, 'display_regcountry' => true, 'display_update' => true, 'display_lastvisit' => true, 'display_contact' => true, 'display_reported' => true, 'display_group' => true, 'display_level' => true, 'display_status' => true, 'display_actions' => true, 'display_newsletter' => true, 'force_check_user' => 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;
        }
    }
    global $DB, $UserSettings, $Settings, $action, $admin_url;
    // query which groups have users (in order to prevent deletion of groups which have users)
    global $usedgroups;
    // We need this in a callback below
    $usedgroups = $DB->get_col('SELECT grp_ID
		FROM T_groups INNER JOIN T_users ON user_grp_ID = grp_ID
		GROUP BY grp_ID');
    // Create result set:
    load_class('users/model/_userlist.class.php', 'UserList');
    $UserList = new UserList($params['filterset_name'], $UserSettings->get('results_per_page'), $params['results_param_prefix'], array('join_group' => $params['join_group'], 'join_city' => $params['join_city'], 'join_country' => $params['join_country'], 'keywords_fields' => $params['keywords_fields'], 'where_status_closed' => $params['where_status_closed'], 'where_org_ID' => $params['org_ID']));
    $default_filters = array('order' => $params['results_order'], 'org' => $params['org_ID']);
    $UserList->title = $params['results_title'];
    $UserList->no_results_text = $params['results_no_text'];
    $UserList->set_default_filters($default_filters);
    $UserList->load_from_Request();
    // Initialize Results object
    users_results($UserList, $params);
    if ($action == 'show_recent') {
        // Sort an users list by "Registered" field
        $UserList->set_order('user_created_datetime');
    }
    // Execute query
    $UserList->query();
    if ($params['display_filters']) {
        // Display the filters
        $filter_presets = array('all' => array(T_('All users'), url_add_param($params['page_url'], 'filter=new')), 'men' => array(T_('Men'), url_add_param($params['page_url'], 'gender_men=1&amp;filter=new')), 'women' => array(T_('Women'), url_add_param($params['page_url'], 'gender_women=1&amp;filter=new')));
        if (is_admin_page()) {
            // Add show only activated users filter only on admin interface
            $filter_presets['activated'] = array(T_('Activated users'), url_add_param($params['page_url'], 'status_activated=1&amp;filter=new'));
            if (is_logged_in() && $current_User->check_perm('users', 'edit')) {
                // Show "Reported Users" filter only for users with edit user permission
                $filter_presets['reported'] = array(T_('Reported users'), url_add_param($params['page_url'], 'reported=1&amp;filter=new'));
            }
        }
        if ($UserList->is_filtered()) {
            // Display link to reset filters only if some filter is applied
            $UserList->global_icon(T_('Reset filters'), 'reset_filters', url_add_param($params['page_url'], 'filter=reset'), T_('Reset filters'), 3, 4, array('class' => 'action_icon btn-warning'));
        }
        $UserList->filter_area = array('callback' => 'callback_filter_userlist', 'url_ignore' => 'users_paged,u_paged,keywords', 'presets' => $filter_presets);
    }
    /*
     * Table icons:
     */
    if ($params['display_btn_refresh']) {
        // Display a button to refresh the users list
        $UserList->global_icon(T_('Refresh users list...'), 'refresh', url_add_param($params['page_url'], 'filter=refresh'), T_('Refresh'), 3, 4, array('class' => 'action_icon btn-warning'));
    }
    if (is_logged_in() && $current_User->check_perm('users', 'edit', false)) {
        if ($params['display_btn_adduser']) {
            // Display a button to add user
            $UserList->global_icon(T_('Create a new user...'), 'new', $admin_url . '?ctrl=user&amp;action=new&amp;user_tab=profile', T_('Add user') . ' &raquo;', 3, 4, array('class' => 'action_icon btn-primary'));
        }
        if ($params['display_btn_adduser']) {
            // Display a button to add group
            $UserList->global_icon(T_('Create a new group...'), 'new', $admin_url . '?ctrl=groups&amp;action=new', T_('Add group') . ' &raquo;', 3, 4);
        }
    }
    // Display result :
    $UserList->display($params['display_params']);
    if ($params['display_newsletter'] && is_logged_in() && $current_User->check_perm('emails', 'edit') && $UserList->result_num_rows > 0) {
        // Newsletter button
        global $admin_url;
        echo '<p class="center">';
        echo '<input type="button" value="' . T_('Send newsletter to the current selection') . '" onclick="location.href=\'' . $admin_url . '?ctrl=campaigns&amp;action=users&amp;' . url_crumb('campaign') . '\'" class="btn btn-default" />';
        echo '</p>';
    }
}