Example #1
0
/**
 * Edit the user
 * @param int The user ID
 * @param string The URL option
 */
function editUser($uid = '0', $option = 'users')
{
    global $database, $my, $acl, $mainframe;
    $msg = checkUserPermissions(array($uid), "edit", true);
    if ($msg) {
        echo "<script type=\"text/javascript\"> alert('" . $msg . "'); window.history.go(-1);</script>\n";
        exit;
    }
    $row = new mosUser($database);
    // load the row from the db table
    $row->load((int) $uid);
    if ($uid) {
        $query = "SELECT *" . "\n FROM #__contact_details" . "\n WHERE user_id = " . (int) $row->id;
        $database->setQuery($query);
        $contact = $database->loadObjectList();
        $row->name = trim($row->name);
        $row->email = trim($row->email);
        $row->username = trim($row->username);
        $row->password = trim($row->password);
    } else {
        $contact = NULL;
        $row->block = 0;
    }
    // check to ensure only super admins can edit super admin info
    if ($my->gid < 25 && $row->gid == 25) {
        mosRedirect('index2.php?option=com_users', _NOT_AUTH);
    }
    $my_group = strtolower($acl->get_group_name($row->gid, 'ARO'));
    if ($my_group == 'super administrator' && $my->gid != 25) {
        $lists['gid'] = '<input type="hidden" name="gid" value="' . $my->gid . '" /><strong>Super Administrator</strong>';
    } else {
        if ($my->gid == 24 && $row->gid == 24) {
            $lists['gid'] = '<input type="hidden" name="gid" value="' . $my->gid . '" /><strong>Administrator</strong>';
        } else {
            // ensure user can't add group higher than themselves
            $my_groups = $acl->get_object_groups('users', $my->id, 'ARO');
            if (is_array($my_groups) && count($my_groups) > 0) {
                $ex_groups = $acl->get_group_children($my_groups[0], 'ARO', 'RECURSE');
            } else {
                $ex_groups = array();
            }
            $gtree = $acl->get_group_children_tree(null, 'USERS', false);
            // remove users 'above' me
            $i = 0;
            while ($i < count($gtree)) {
                if (in_array($gtree[$i]->value, $ex_groups)) {
                    array_splice($gtree, $i, 1);
                } else {
                    $i++;
                }
            }
            $lists['gid'] = mosHTML::selectList($gtree, 'gid', 'size="10"', 'value', 'text', $row->gid);
        }
    }
    // build the html select list
    $lists['block'] = mosHTML::yesnoRadioList('block', 'class="inputbox" size="1"', $row->block);
    // build the html select list
    $lists['sendEmail'] = mosHTML::yesnoRadioList('sendEmail', 'class="inputbox" size="1"', $row->sendEmail);
    $file = $mainframe->getPath('com_xml', 'com_users');
    $params = new mosUserParameters($row->params, $file, 'component');
    HTML_users::edituser($row, $contact, $lists, $option, $uid, $params);
}
Example #2
0
function editUser($uid = '0', $option = 'users')
{
    global $database, $my, $acl;
    $row = new mosUser($database);
    // load the row from the db table
    $row->load($uid);
    if ($uid) {
        $query = "SELECT * FROM #__contact_details WHERE user_id='" . $row->id . "'";
        $database->setQuery($query);
        $contact = $database->loadObjectList();
    } else {
        $contact = NULL;
        $row->block = 0;
    }
    // check to ensure only super admins can edit super admin info
    if ($my->gid < 25 && $row->gid == 25) {
        mosRedirect('index2.php?option=com_users', T_('You are not authorized to view this resource.'));
    }
    $my_group = strtolower($acl->get_group_name($row->gid, 'ARO'));
    if ($my_group == 'super administrator') {
        $lists['gid'] = '<input type="hidden" name="gid" value="' . $my->gid . '" /><strong>' . T_('Super Administrator') . '</strong>';
    } else {
        if ($my->gid == 24 && $row->gid == 24) {
            $lists['gid'] = '<input type="hidden" name="gid" value="' . $my->gid . '" /><strong>' . T_('Administrator') . '</strong>';
        } else {
            // ensure user can't add group higher than themselves
            $my_groups = $acl->get_object_groups('users', $my->id, 'ARO');
            if (is_array($my_groups) && count($my_groups) > 0) {
                $ex_groups = $acl->get_group_children($my_groups[0], 'ARO', 'RECURSE');
                if (!$ex_groups) {
                    $ex_groups = array();
                }
            } else {
                $ex_groups = array();
            }
            $gtree = $acl->get_group_children_tree(null, 'USERS', false);
            // remove users 'above' me
            $i = 0;
            while ($i < count($gtree)) {
                if (in_array($gtree[$i]->value, $ex_groups)) {
                    array_splice($gtree, $i, 1);
                } else {
                    $i++;
                }
            }
            $lists['gid'] = mosHTML::selectList($gtree, 'gid', 'size="10"', 'value', 'text', $row->gid);
        }
    }
    // build the html select list
    $lists['block'] = mosHTML::yesnoRadioList('block', 'class="inputbox" size="1"', $row->block);
    // build the html select list
    $lists['sendEmail'] = mosHTML::yesnoRadioList('sendEmail', 'class="inputbox" size="1"', $row->sendEmail);
    HTML_users::edituser($row, $contact, $lists, $option, $uid);
}
Example #3
0
function editUser($uid = '0', $option = 'users')
{
    global $database, $my, $acl, $adminLanguage;
    $row = new mosUser($database);
    // load the row from the db table
    $row->load($uid);
    if ($uid) {
        $query = "SELECT * FROM #__contact_details WHERE user_id='" . $row->id . "'";
        $database->setQuery($query);
        $contact = $database->loadObjectList();
    } else {
        $contact = NULL;
    }
    $my_group = strtolower($acl->get_group_name($row->gid, 'ARO'));
    if ($my_group == 'super administrator') {
        $lists['gid'] = '<input type="hidden" name="gid" value="' . $my->gid . '" /><strong>' . $adminLanguage->A_COMP_USERS_SUPER_ADMIN . '</strong>';
    } else {
        // ensure user can't add group higher than themselves
        $my_groups = $acl->get_object_groups('users', $my->id, 'ARO');
        if (is_array($my_groups) && count($my_groups) > 0) {
            $ex_groups = $acl->get_group_children($my_groups[0], 'ARO', 'RECURSE');
        } else {
            $ex_groups = array();
        }
        $gtree = $acl->get_group_children_tree(null, 'USERS', false);
        // remove users 'above' me
        $i = 0;
        while ($i < count($gtree)) {
            if (in_array($gtree[$i]->value, $ex_groups)) {
                array_splice($gtree, $i, 1);
            } else {
                $i++;
            }
        }
        $lists['gid'] = mosHTML::selectList($gtree, 'gid', 'size="4"', 'value', 'text', $row->gid);
    }
    // build the html select list
    $lists['block'] = mosHTML::yesnoRadioList('block', 'class="inputbox" size="1"', $row->block);
    // build the html select list
    $lists['sendEmail'] = mosHTML::yesnoRadioList('sendEmail', 'class="inputbox" size="1"', $row->sendEmail);
    HTML_users::edituser($row, $contact, $lists, $option, $uid);
}