예제 #1
0
/**
 * Display user report form
 *
 * @param array Params
 */
function user_report_form($params = array())
{
    global $current_User;
    $params = array_merge(array('Form' => NULL, 'user_ID' => 0, 'crumb_name' => '', 'cancel_url' => ''), $params);
    if (!is_logged_in() || $current_User->ID == $params['user_ID'] || !$current_User->check_status('can_report_user')) {
        // Current user must be logged in, cannot report own account, and must has a permission to report
        return;
    }
    $Form =& $params['Form'];
    $Form->add_crumb($params['crumb_name']);
    $Form->hidden('user_ID', $params['user_ID']);
    $report_options = array_merge(array('none' => ''), get_report_statuses());
    $Form->custom_content('<p><strong>' . get_icon('warning_yellow') . ' ' . T_('If you have an issue with this user, you can report it here:') . '</strong></p>');
    // get current User report from edited User
    $current_report = get_report_from($params['user_ID']);
    if ($current_report == NULL) {
        // currentUser didn't add any report from this user yet
        $report_content = '<select id="report_user_status" name="report_user_status">';
        foreach ($report_options as $option => $option_label) {
            // add select option, none must be selected
            $report_content .= '<option ' . ($option == 'none' ? 'selected="selected" ' : '') . 'value="' . $option . '">' . $option_label . '</option>';
        }
        $report_content .= '</select><div id="report_info" style="width:100%;"></div>';
        $info_content = '<div><span>' . T_('You can provide additional information below') . ':</span></div>';
        $info_content .= '<table style="width:100%;"><td style="width:99%;background-color:inherit;"><textarea id="report_info_content" name="report_info_content" class="form_textarea_input" style="width:100%;" rows="2" maxlength="240"></textarea></td>';
        $info_content .= '<td style="vertical-align:top;background-color:inherit;"><input type="submit" class="SaveButton" style="color:red;margin-left:2px;" value="' . T_('Report this user now!') . '" name="actionArray[report_user]" /></td></table>';
        $report_content .= '<script type="text/javascript">
			var info_content = \'' . $info_content . '\';
			jQuery("#report_user_status").change( function() {
				var report_info = jQuery("#report_info");
				var value = jQuery(this).val();
				if( value == "none" )
				{
					report_info.html("");
				}
				else if( report_info.is(":empty") )
				{
					report_info.html( info_content );
				}
			});
			</script>';
        $report_content .= '<noscript>' . $info_content . '</noscript>';
        $Form->info(T_('Report NOW'), $report_content);
    } else {
        $report_content = T_('You have reported this user on %s as "%s" with the additional info "%s" - <a %s>Cancel report</a>');
        $report_content = sprintf($report_content, mysql2localedatetime($current_report['date']), $report_options[$current_report['status']], $current_report['info'], 'href="' . $params['cancel_url'] . '"');
        $Form->info(T_('Already reported'), $report_content);
    }
}
예제 #2
0
    if ($is_contact === NULL || $is_contact === true) {
        // Display a button to block user
        $buttons['group'][] = '<a href="' . $contact_block_url . '&action=block" class="btn btn-warning">' . '<button type="button">' . T_('Block Contact') . '</button>' . '</a>';
    } else {
        // Display a button to unblock user
        $buttons['group'][] = '<a href="' . $contact_block_url . '&action=unblock" class="btn btn-danger">' . '<button type="button">' . T_('Unblock Contact') . '</button>' . '</a>';
    }
}
// - Report:
if ($is_logged_in && $current_User->ID != $User->ID && $current_User->check_status('can_report_user')) {
    // Current user must be logged in, cannot report own account, and must has a permission to report
    if (!isset($buttons['group'])) {
        $buttons['group'] = array();
    }
    // get current User report from edited User
    $current_report = get_report_from($User->ID);
    if ($current_report == NULL) {
        // current User didn't add any report from this user yet
        $buttons['group'][] = '<button type="button" class="btn btn-warning" onclick="return user_report( ' . $User->ID . ' )">' . T_('Report User') . '</button>';
    } else {
        $buttons['group'][] = '<button type="button" class="btn btn-danger" onclick="return user_report( ' . $User->ID . ' )">' . T_('Edit Reported User') . '</button>';
    }
}
if ($user_perms_edit) {
    // Current user can edit other user's profiles
    global $admin_url;
    // - Edit in back-office:
    $buttons[] = '<a href="' . url_add_param($admin_url, 'ctrl=user&amp;user_ID=' . $User->ID) . '">' . '<button type="button" class="btn btn-primary">' . $params['edit_user_admin_link_text'] . '</button>' . '</a>';
    if ($current_User->ID != $User->ID && $current_User->check_perm('users', 'edit')) {
        // - Delete in back-office:
        $buttons['del'] = array();
예제 #3
0
/**
 * Display user report form
 *
 * @param array Params
 */
function user_report_form($params = array())
{
    global $current_User, $display_mode;
    $params = array_merge(array('Form' => NULL, 'user_ID' => 0, 'crumb_name' => '', 'cancel_url' => ''), $params);
    if (!is_logged_in() || $current_User->ID == $params['user_ID'] || !$current_User->check_status('can_report_user')) {
        // Current user must be logged in, cannot report own account, and must has a permission to report
        return;
    }
    $Form =& $params['Form'];
    $Form->add_crumb($params['crumb_name']);
    $Form->hidden('user_ID', $params['user_ID']);
    $report_options = array_merge(array('none' => ''), get_report_statuses());
    // Use JS to show/hide textarea only for normal view
    $use_js = !(isset($display_mode) && $display_mode == 'js');
    // get current User report from edited User
    $current_report = get_report_from($params['user_ID']);
    if ($current_report == NULL) {
        // currentUser didn't add any report from this user yet
        $Form->custom_content('<p class="alert alert-warning"><strong>' . get_icon('warning_yellow') . ' ' . T_('If you have an issue with this user, you can report it here:') . '</strong></p>');
        $report_content = '<select id="report_user_status" name="report_user_status" class="form-control" style="width:auto">';
        foreach ($report_options as $option => $option_label) {
            // add select option, none must be selected
            $report_content .= '<option ' . ($option == 'none' ? 'selected="selected" ' : '') . 'value="' . $option . '">' . $option_label . '</option>';
        }
        $report_content .= '</select><div id="report_info" style="width:100%;">$report_info_content$</div>';
        $info_content = '<br />' . T_('You can provide additional information below') . ':';
        $info_content .= '<textarea id="report_info_content" name="report_info_content" class="form_textarea_input form-control" rows="2" maxlength="240"></textarea>';
        $info_content .= '<br /><input type="submit" class="SaveButton btn btn-danger" value="' . T_('Report this user now!') . '" name="actionArray[report_user]" />';
        if ($use_js) {
            $report_content = str_replace('$report_info_content$', '', $report_content);
            $report_content .= '<script type="text/javascript">
				var info_content = \'' . $info_content . '\';
				jQuery("#report_user_status").change( function() {
					var report_info = jQuery("#report_info");
					var value = jQuery(this).val();
					if( value == "none" )
					{
						report_info.html("");
					}
					else if( report_info.is(":empty") )
					{
						report_info.html( info_content );
					}
				});
				</script>';
            $report_content .= '<noscript>' . $info_content . '</noscript>';
        } else {
            $report_content = str_replace('$report_info_content$', $info_content, $report_content);
        }
        $Form->info(T_('Reason'), $report_content);
    } else {
        echo '<div id="current_modal_title" style="display:none">' . T_('Already Reported User') . '</div>';
        printf(T_('You have reported this user on %s<br />as "%s"<br />with the additional info "%s"'), mysql2localedatetime($current_report['date']), $report_options[$current_report['status']], nl2br($current_report['info']));
        echo '<p><a href="' . $params['cancel_url'] . '" class="btn btn-warning">' . T_('Cancel Report') . '</a></p>';
    }
}