1
ccrstudioweb
subgroup may administrate the admin group?

Xoops 2.0.18

Hi,
I went throught an interesting issue:
I create a group called SELECIONADOR and gave it the permission to manage groups, I mean, when a visitor register, he give some information in order to be alocated by SELECIONADOR to especific group: ALUNO, PROFESSOR or COLABORADOR.

So SELECIONADOR enters admin>>edit user and activate this new user, after SELECIONADOR check out the information given by visitor and alocate this user to the new group.

The problem is in *choose the group*:
Instead this:
ADMINISTRATOR
USER
SELECIONADOR
COLABORADOR
ALUNO
PROFESSOR

I want this:
USER
SELECIONADOR
COLABORADOR
ALUNO
PROFESSOR

I don´t want SELECIONADOR the option to create a new ADMINISTRATOR

Any help is welcome!

2
ccrstudioweb
Re: subgroup may administrate the admin group?

The line for the select item:
modules/system/admin/users/userform.php line 168:

$group_select[] = new XoopsFormSelectGroup('(!)'._US_GROUPS.'''groups'false$groups5true);


It generates this:

<tr align="left" valign="top"><td class="head"><div class="xoops-form-element-caption"><span class="caption-text"><font style="font-size: 17px; color: rgb(166, 87, 0);">(!)Grupos de Usuáriosfont>span><span class="caption-marker">*span>div>td><td class="even"><select size="5" name="groups[]" id="groups[]" multiple="multiple">
<
option value="1">ADMINISTRATORoption>
<
option value="2" selected="selected">USERoption>
<
option value="5">SELECIONADORoption>
<
option value="6">COLABORADORoption>
<
option value="7">ALUNOoption>
<
option value="9">PROFESSORoption>
select>td>tr>

3
ccrstudioweb
Re: subgroup may administrate the admin group?

Each group has an g_id=1, 2,...
How can I tell the PHP to omit some g_ids in the array groups?

4
ccrstudioweb
Re: subgroup may administrate the admin group?

I think is possible to hide some groups changing the /class/xoopsform/formselectgroup.php

I´m trying here...

5
ghia
Re: subgroup may administrate the admin group?
  • 2010/9/7 7:28

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Provide an additional parameter with default value for the function and set this parameter for the function call in userform.php
See the parameter to include the anonymous group or not. You could make it the same way for the administrator group.




6
ccrstudioweb
Re: subgroup may administrate the admin group?

Hi Ghia,
I´ve found!

In kernel/groups.php I change from:

/**
     * retrieve groups from the database
     * @param object $criteria {@link CriteriaElement} with conditions for the groups
     * @param bool $id_as_key should the groups' IDs be used as keys for the associative array?
     * @return mixed Array of groups
     */

   
function getObjects($criteria null$id_as_key false)
    {
        
$ret = array();
        
$limit $start 0;
        
$sql 'SELECT * FROM '.$this->db->prefix('groups');
        if (isset(
$criteria) && is_subclass_of($criteria'criteriaelement')) {
            
$sql .= ' '.$criteria->renderWhere();
            
$limit $criteria->getLimit();
            
$start $criteria->getStart();
        }
        
$result $this->db->query($sql$limit$start);
        if (!
$result) {
            return 
$ret;
        }
        while (
$myrow $this->db->fetchArray($result)) {
            
$group = new XoopsGroup();
            
$group->assignVars($myrow);
            if (!
$id_as_key) {
                
$ret[] =& $group;
            } else {
                
$ret[$myrow['groupid']] =& $group;
            }
            unset(
$group);
        }
        return 
$ret;
    }*/



to:



/**
     * retrieve groups from the database
     *
     * @param object $criteria {@link CriteriaElement} with conditions for the groups
     * @param bool $id_as_key should the groups' IDs be used as keys for the associative array?
     * @return mixed Array of groups
     */

function getObjects($criteria null$id_as_key false)
    {
        
$ret = array();
        
$limit $start 0;
        
$sql 'SELECT * FROM '.$this->db->prefix('groups');
        if (isset(
$criteria) && is_subclass_of($criteria'criteriaelement')) {
            
$sql .= ' '.$criteria->renderWhere();
////////////////////HERE///////////////////////
            
$limit 4;
            
$start 1;
/////////////////////////////////////////////////
        
}
        
$result $this->db->query($sql$limit$start);
        if (!
$result) {
            return 
$ret;
        }
        while (
$myrow $this->db->fetchArray($result)) {
            
$group = new XoopsGroup();
            
$group->assignVars($myrow);
            if (!
$id_as_key) {
                
$ret[] =& $group;
            } else {
                
$ret[$myrow['groupid']] =& $group;
            }
            unset(
$group);
        }
        return 
$ret;
    }


As you are one xoops especialist, do you think this change may
alternate some function?

Thank you!
My Google Maps API3 and Xoops integration (Cool!):
http://www.esterecomendo.com.br/portal/

7
ccrstudioweb
Re: subgroup may administrate the admin group?

Let me update the solution:
kernel/group.php
if (isset($criteria) && is_subclass_of($criteria'criteriaelement')) {
            
$sql .= ' '.$criteria->renderWhere();
            
$limit $criteria->getLimit();
            
$start $criteria->getStart();
        }

to:
if (isset($criteria) && is_subclass_of($criteria'criteriaelement'))
 {
            
$sql .= ' '.$criteria->renderWhere();
            
$limit 4;//number of itens in droplist
            
$start 1;//it gives groups 2,3,4,.... except ADMIN      }

and
System/admin/users/userform.php
Here I gave in ADMIN AREA to group SELECIONADOR no rights to edit groups, only users. So XOOPS give an automated dropdown lis of the groups name.
else {
    foreach (
$groups as $key => $group) {
    
$group_select[] = new XoopsFormHidden('groups[' $key 
']'$group);            
    }

So I changed the former code to the folowing, forcing the COLABORADOR to see the group´s name dropdownlist.
Added a condition $uid_value == '1' in order to COLABORADOR not see ADMIN´s group´s name dropdownlist. Admin continue to see all (global):
else {
if (
$uid_value == '1') {$group_select[] = new 
XoopsFormHidden('groups[' $key ']'$group);    } else 
{
$group_select[] = new XoopsFormSelectGroup('style="font-size: 17px; color: #A65700">
(!)'
._US_GROUPS.'''groups'false$groups5true);}}

8
ghia
Re: subgroup may administrate the admin group?
  • 2010/9/11 7:14

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


- Not sure if group selection functions as in eg permissions for categories or blocks are not affected by this.
- If you have more then 5 groups, you can run into trouble.
- The same if other persons then uid 1 are in the admin group.

9
ccrstudioweb
Re: subgroup may administrate the admin group?

I think this solution works for me, in my case: I have only one admin and five groups. I tested the system using the diferents groups and everything is ok now. As I had no idea how to restrict this kind of access I opened this post. So This may be a REFERENCE only.
Ghia thank you for the help and the tip about creating other references/routines beyond the originals. I´m using them in other situations! Once I´m not so good in php, these are gold.
Thank You!
My Google Maps API3 and Xoops integration (Cool!):
http://www.esterecomendo.com.br/portal/

Login

Who's Online

172 user(s) are online (89 user(s) are browsing Support Forums)


Members: 0


Guests: 172


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits