示例#1
0
 $report_status = param('report_user_status', 'string', '');
 $report_info = param('report_info_content', 'text', '');
 $user_ID = param('user_ID', 'integer', 0);
 $user_tab = param('user_tab', 'string');
 if (get_report_status_text($report_status) == '') {
     // A report status is incorrect
     $Messages->add(T_('Please select the correct report reason!'), 'error');
     $user_tab = 'report';
 }
 if (!param_errors_detected()) {
     // add report and block contact ( it will be blocked if was already on this user contact list )
     add_report_from($user_ID, $report_status, $report_info);
     $blocked_message = '';
     if ($current_User->check_perm('perm_messaging', 'reply')) {
         // user has messaging permission, set/add this user as blocked contact
         $contact_status = check_contact($user_ID);
         if ($contact_status == NULL) {
             // contact doesn't exists yet, create as blocked contact
             create_contacts_user($user_ID, true);
             $blocked_message = ' ' . T_('You have also blocked this user from contacting you in the future.');
         } elseif ($contact_status) {
             // contact exists and it's not blocked, set as blocked
             set_contact_blocked($user_ID, 1);
             $blocked_message = ' ' . T_('You have also blocked this user from contacting you in the future.');
         }
     }
     $Messages->add(T_('The user was reported.') . $blocked_message, 'success');
 }
 // Redirect so that a reload doesn't write to the DB twice:
 if (param('is_backoffice', 'integer', 0)) {
     header_redirect($admin_url . '?ctrl=user&user_tab=' . $user_tab . '&user_ID=' . $user_ID, 303);
示例#2
0
/**
 * Insert user to contacts
 *
 * @param integer User ID
 * @param boolean set true to add as a blocked contact
 * @return true if success, else false
 */
function create_contacts_user($user_ID, $blocked = false)
{
    global $DB, $current_User, $localtimenow;
    $contact = check_contact($user_ID);
    if (!is_null($contact)) {
        // This user already exists in the contact list for current user
        return true;
    }
    $datetime = date('Y-m-d H:i:s', $localtimenow);
    $blocked = $blocked ? 1 : 0;
    $sql = 'INSERT INTO T_messaging__contact
		       ( mct_from_user_ID, mct_to_user_ID, mct_blocked, mct_last_contact_datetime )
		VALUES ( ' . $current_User->ID . ', ' . $user_ID . ', ' . $blocked . ', ' . $DB->quote($datetime) . ' )';
    return $DB->query($sql, 'Insert contacts');
}
示例#3
0
}
// Check if current user can edit other users from back-office:
$user_perms_edit = $is_logged_in && $current_User->can_moderate_user($User->ID) && $current_User->check_status('can_access_admin') && $current_User->check_perm('admin', 'restricted');
// - Message:
if (!$is_logged_in || $current_User->ID != $User->ID) {
    // Display a message to send a button only for other users
    $msgform_url = $User->get_msgform_url($Blog->get('msgformurl'));
    if (!empty($msgform_url)) {
        $msgform_url = url_add_param($msgform_url, 'msg_type=PM');
        $buttons[] = '<a href="' . $msgform_url . '"><button type="button" class="btn ' . ($user_perms_edit ? 'btn-default' : 'btn-primary') . '">' . T_('Send Message') . '</button></a>';
    }
}
// - Contact:
if ($is_logged_in && $current_User->ID != $User->ID && $current_User->check_perm('perm_messaging', 'reply') && $current_User->check_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($User->ID);
    if ($is_contact === NULL) {
        // User is not in current User contact list, so allow "Add to my contacts" action
        $buttons[] = '<button type="button" class="btn btn-default" onclick="return user_contact_groups( ' . $User->ID . ' )">' . T_('Add to Contacts') . '</button>';
    } elseif ($is_contact === false) {
        // User is blocked
        $buttons[] = '<button type="button" class="btn btn-danger" onclick="return user_contact_groups( ' . $User->ID . ' )">' . T_('Edit Blocked Contact') . '</button>';
    } else {
        // User is on current User contact list
        $buttons[] = '<button type="button" class="btn btn-success" onclick="return user_contact_groups( ' . $User->ID . ' )">' . T_('Edit Contact') . '</button>';
    }
    $buttons['group'] = array();
    $contact_block_url = get_samedomain_htsrv_url() . 'action.php?mname=messaging&amp;disp=contacts&amp;user_ID=' . $user_ID . '&amp;redirect_to=' . rawurlencode(regenerate_url()) . '&amp;' . url_crumb('messaging_contacts');
    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>';
示例#4
0
 * @var the action destination of the form (NULL for pagenow)
 */
global $form_action;
$Form = new Form($form_action, 'user_checkchanges');
$form_class = 'fform user_contact_form';
$Form->title_fmt = '<span style="float:right">$global_icons$</span><div>$title$</div>' . "\n";
$Form->begin_form($form_class);
$Form->hidden('blog', $Blog->ID);
$Form->add_crumb('user');
$Form->hidden('user_ID', $edited_User->ID);
$close_icon = '';
if ($display_mode == 'js') {
    // Display a close link for popup window
    $close_icon = action_icon(T_('Close this window'), 'close', '', '', 0, 0, array('id' => 'close_button', 'class' => 'floatright'));
}
$Form->begin_fieldset(T_('Contact Groups') . $close_icon, array('class' => 'fieldset clear'));
// Contact groups:
$current_user_groups = get_contacts_groups_array();
$active_groups = get_contacts_groups_by_user_ID($edited_User->ID);
$is_contact = check_contact($edited_User->ID);
$group_options = array();
foreach ($current_user_groups as $group_ID => $group_title) {
    $group_options[] = array('contact_groups[]', $group_ID, $group_title, in_array($group_ID, $active_groups));
}
$group_options[] = array('contact_groups[]', 'new', T_('new') . ': <input type="text" name="contact_group_new" class="form-control" />', false, false, '', 'contact_group_new');
$Form->checklist($group_options, 'contact_groups', '', false, false, array('wide' => true));
// Block the contact:
$blocked_options = array(array('contact_blocked', 1, T_('Block this contact from contacting you.'), $is_contact === false));
$Form->checklist($blocked_options, 'contact_blocked', '', false, false, array('wide' => true));
$Form->end_fieldset();
$Form->end_form(array(array('value' => T_('Save'), 'name' => 'actionArray[contact_group_save]')));