Пример #1
0
/**
 * Get HTML component select all users
 *
 * @return string HTML component select
 */
function credit_html_select_user()
{
    global $user_config;
    if (auth_isadmin()) {
        $admins = user_getallwithstatus(2);
        $users = user_getallwithstatus(3);
    }
    $subusers = user_getsubuserbyuid($user_config['uid']);
    if (count($admins) > 0) {
        $option_user .= '<optgroup label="' . _('Administrators') . '">';
        foreach ($admins as $admin) {
            $option_user .= '<option value="' . $admin['uid'] . '">' . $admin['name'] . ' (' . $admin['username'] . ') - ' . _('Administrator') . '</option>';
        }
        $option_user .= '</optgroup>';
    }
    if (count($users) > 0) {
        $option_user .= '<optgroup label="' . _('Users') . '">';
        foreach ($users as $user) {
            $option_user .= '<option value="' . $user['uid'] . '">' . $user['name'] . ' (' . $user['username'] . ') - ' . _('User') . '</option>';
        }
        $option_user .= '</optgroup>';
    }
    if (count($subusers) > 0) {
        $option_user .= '<optgroup label="' . _('Subusers') . '">';
        foreach ($subusers as $subuser) {
            $option_user .= '<option value="' . $subuser['uid'] . '">' . $subuser['name'] . ' (' . $subuser['username'] . ') - ' . _('Subuser') . '</option>';
        }
        $option_user .= '</optgroup>';
    }
    $select_user = '******' . $option_user . '</select>';
    return $select_user;
}
Пример #2
0
        if ($user_edited['parent_uid'] == $user_config['uid']) {
            $is_parent = TRUE;
        } else {
            auth_block();
        }
    }
}
$show_status_hint = FALSE;
$allow_edit_status = FALSE;
$allow_edit_parent = FALSE;
if (auth_isadmin()) {
    // if edited user IS NOT currently logged in admin or admin with user ID 1 (username: admin) or status is admin
    if (!($user_edited['uid'] == $user_config['uid'] || $user_edited['uid'] == 1 || $user_edited['status'] == 2)) {
        $allow_edit_status = TRUE;
    }
    $list = user_getsubuserbyuid($user_edited['uid']);
    if (count($list) > 0) {
        $show_status_hint = TRUE;
        $allow_edit_status = FALSE;
    }
    if ($user_edited['status'] == 4) {
        $allow_edit_parent = TRUE;
    }
}
switch (_OP_) {
    case "user_pref":
        if ($c_user = dba_search(_DB_PREF_ . '_tblUser', '*', array('flag_deleted' => 0, 'username' => $c_username))) {
            if ($allow_edit_status) {
                $status = (int) $c_user[0]['status'];
            }
            if ($allow_edit_parent) {
Пример #3
0
     $add['credit'] = 0;
     // add user
     $ret = user_add($add);
     if (is_array($ret)) {
         $_SESSION['dialog']['info'][] = $ret['error_string'];
     } else {
         $_SESSION['dialog']['info'][] = _('Unable to process user addition');
     }
     header("Location: " . _u('index.php?app=main&inc=core_user&route=user_mgmnt&op=user_add&view=' . $view));
     exit;
     break;
 case "user_del":
     $up['username'] = $_REQUEST['uname'];
     $del_uid = user_username2uid($up['username']);
     // users cannot be removed if they still have subusers
     $subusers = user_getsubuserbyuid($del_uid);
     if (count($subusers) > 0) {
         $ret['error_string'] = _('Unable to delete this user until all subusers under this user have been removed');
     } else {
         $ret = user_remove($del_uid);
     }
     $_SESSION['dialog']['info'][] = $ret['error_string'];
     header("Location: " . _u('index.php?app=main&inc=core_user&route=user_mgmnt&op=user_list&view=' . $view));
     exit;
     break;
 case "user_unban":
     $uid = user_username2uid($_REQUEST['uname']);
     if (user_banned_get($uid)) {
         if (user_banned_remove($uid)) {
             $_SESSION['dialog']['info'][] = _('Account has been unbanned') . ' (' . _('username') . ': ' . $_REQUEST['uname'] . ')';
         } else {
Пример #4
0
function themes_select_users_single($select_field_name, $selected_value = '', $tag_params = array(), $css_id = '', $css_class = '')
{
    global $user_config;
    $ret = '';
    if (core_themes_get()) {
        $ret = core_hook(core_themes_get(), 'themes_select_users_single', array($select_field_name, $selected_value, $tag_params, $css_id, $css_class));
    }
    if (!$ret) {
        if (!is_array($selected_value)) {
            $selected_value = array($selected_value);
        }
        if (auth_isadmin()) {
            $admins = user_getallwithstatus(2);
            $users = user_getallwithstatus(3);
        }
        $subusers = user_getsubuserbyuid($user_config['uid']);
        $option_user .= '<option value="0">' . _('Select users') . '</option>';
        if (count($admins) > 0) {
            $option_user .= '<optgroup label="' . _('Administrators') . '">';
            foreach ($admins as $admin) {
                $selected = '';
                foreach ($selected_value as $sv) {
                    if ($admin['uid'] == $sv) {
                        $selected = 'selected';
                        break;
                    }
                }
                $option_user .= '<option value="' . $admin['uid'] . '" ' . $selected . '>' . $admin['name'] . ' (' . $admin['username'] . ') - ' . _('Administrator') . '</option>';
            }
            $option_user .= '</optgroup>';
        }
        if (count($users) > 0) {
            $option_user .= '<optgroup label="' . _('Users') . '">';
            foreach ($users as $user) {
                $selected = '';
                foreach ($selected_value as $sv) {
                    if ($user['uid'] == $sv) {
                        $selected = 'selected';
                        break;
                    }
                }
                $option_user .= '<option value="' . $user['uid'] . '" ' . $selected . '>' . $user['name'] . ' (' . $user['username'] . ') - ' . _('User') . '</option>';
            }
            $option_user .= '</optgroup>';
        }
        if (count($subusers) > 0) {
            $option_user .= '<optgroup label="' . _('Subusers') . '">';
            foreach ($subusers as $subuser) {
                $selected = '';
                foreach ($selected_value as $sv) {
                    if ($subuser['uid'] == $sv) {
                        $selected = 'selected';
                        break;
                    }
                }
                $option_user .= '<option value="' . $subuser['uid'] . '"' . $selected . '>' . $subuser['name'] . ' (' . $subuser['username'] . ') - ' . _('Subuser') . '</option>';
            }
            $option_user .= '</optgroup>';
        }
        $css_id = trim($css_id) ? trim($css_id) : 'playsms-select-users-single-' . core_sanitize_alphanumeric($select_field_name);
        if (is_array($tag_params)) {
            foreach ($tag_params as $key => $val) {
                $params .= ' ' . $key . '="' . $val . '"';
            }
        }
        $placeholder = $tag_params['placeholder'] ? $tag_params['placeholder'] : _('Select users');
        $width = $tag_params['width'] ? $tag_params['width'] : 'resolve';
        $js = '
			<script language="javascript" type="text/javascript">
				$(document).ready(function() {
					$("#' . $css_id . '").select2({
						placeholder: "' . $placeholder . '",
						width: "' . $width . '",
						separator: [\',\'],
						tokenSeparators: [\',\'],
					});
				});
			</script>
		';
        $ret = $js . PHP_EOL . '<select name="' . $select_field_name . '" id="' . $css_id . '" class="playsms-select ' . $css_class . '" ' . $params . '>' . $option_user . '</select>';
        return $ret;
    }
}
Пример #5
0
/**
 * Delete existing user
 *
 * @param integer $uid
 *        User ID
 * @return array $ret('error_string', 'status')
 */
function user_remove($uid, $forced = FALSE)
{
    global $user_config;
    $ret['error_string'] = _('Unknown error has occurred');
    $ret['status'] = FALSE;
    if ($forced || auth_isadmin() || $user_config['status'] == 3) {
        if ($username = user_uid2username($uid)) {
            if (!($uid == 1)) {
                if ($uid == $user_config['uid']) {
                    $ret['error_string'] = _('Currently logged in user is immune to deletion');
                } else {
                    $subusers = user_getsubuserbyuid($uid);
                    if (count($subusers) > 0) {
                        $ret['error_string'] = _('Unable to delete this user until all subusers under this user have been removed');
                        return $ret;
                    }
                    if ($user_config['status'] == 3) {
                        $parent_uid = user_getparentbyuid($uid);
                        if ($parent_uid != $user_config['uid']) {
                            $ret['error_string'] = _('Unable to delete other users');
                            return $ret;
                        }
                    }
                    if (dba_update(_DB_PREF_ . '_tblUser', array('c_timestamp' => mktime(), 'flag_deleted' => 1), array('flag_deleted' => 0, 'uid' => $uid))) {
                        user_banned_remove($uid);
                        _log('user removed u:' . $username . ' uid:' . $uid, 2, 'user_remove');
                        $ret['error_string'] = _('Account has been removed') . " (" . _('username') . ": " . $username . ")";
                        $ret['status'] = TRUE;
                    }
                }
            } else {
                $ret['error_string'] = _('User is immune to deletion') . " (" . _('username') . ": " . $username . ")";
            }
        } else {
            $ret['error_string'] = _('User does not exist');
        }
    } else {
        $ret['error_string'] = _('User deletion unavailable');
    }
    return $ret;
}