Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

User groups selection in Profile

Asked Modified Viewed 3,526 times
B
bvcweb
B
bvcweb 10
  • Newbie, joined since
  • Contributed 7 posts on the community forums.
  • Started 3 threads in the forums
  • Started this discussions
asked
Newbie

I've set 12 user groups. The id's starts at 1 and goes on to 12.
In de table "User" the user groups are stored per user. A .(dot) is the seperator between every user group.

I choose a user group for a user but if I have choose the user group with id 10 or higher, then id 1 is out of the selection. But id 1 is not selected to the user.

Is there a solution to this?
Thankx a lot.
0 replies

5 posts

W
WEC
W
WEC 10
  • Veteran Member, joined since
  • Contributed 946 posts on the community forums.
  • Started 5 threads in the forums
answered
Veteran Member

In v. 7.01.01 i found that the selected user group would not stick being displayed when selected for editing in user groups admin.

Solution:

In administration\user_groups.php find:

    if (dbrows($result)) {
        opentable($locale['420']);
        echo "<form name='selectform' method='post' action='".FUSION_SELF.$aidlink."'>\n";
        echo "<div style='text-align:center'>\n<select name='group_id' class='textbox'>\n";
        $sel = "";
        while ($data = dbarray($result)) {
            if (isset($group_id)) $sel = ($group_id == $data['group_id'] ? " selected='selected'" : "");
            echo "<option value='".$data['group_id']."'$sel>[".$data['group_id']."] ".$data['group_name']."</option>\n";
        }
        echo "</select>\n<input type='submit' name='edit' value='".$locale['421']."' class='button' />\n";
        echo "<input type='submit' name='delete' value='".$locale['422']."' onclick='return DeleteGroup();' class='button' />\n";
        echo "</div>\n</form>\n";
        closetable();
    }


Replace with:

    if (dbrows($result)) {
        opentable($locale['420']);
        echo "<form name='selectform' method='post' action='".FUSION_SELF.$aidlink."'>\n";
        echo "<div style='text-align:center'>\n<select name='group_id' class='textbox'>\n";
        //$sel = "";
        $editlist = ""; $sel = "";
        while ($data = dbarray($result)) {
            //if (isset($group_id)) $sel = ($group_id == $data['group_id'] ? " selected='selected'" : "");
            if (isset($_POST['group_id'])) { $sel = ($_POST['group_id'] == $data['group_id'] ? " selected='selected'" : "");}
            //echo "<option value='".$data['group_id']."'$sel>[".$data['group_id']."] ".$data['group_name']."</option>\n";
            $editlist .= "<option value='".$data['group_id']."'$sel>[".$data['group_id']."] ".$data['group_name']."</option>\n";
        }
        //echo "</select>\n<input type='submit' name='edit' value='".$locale['421']."' class='button' />\n";
        echo $editlist."</select>\n<input type='submit' name='edit' value='".$locale['421']."' class='button' />\n";
        echo "<input type='submit' name='delete' value='".$locale['422']."' onclick='return DeleteGroup();' class='button' />\n";
        echo "</div>\n</form>\n";
        closetable();
    }


Check if this solves your problem.
0 replies
B
bvcweb
B
bvcweb 10
  • Newbie, joined since
  • Contributed 7 posts on the community forums.
  • Started 3 threads in the forums
  • Started this discussions
answered
Newbie

No, this is not my problem.

My problem is in the file profile.php
I will add an user to an user group. But if I set an user group with user group id 10 to a user, the selection box have all the user groups minus id=10 AND ID=1. But id=1 is not selected to that user.

In this piece of code you see the display of the user-groups for the user:
if ($user_data['user_groups']) {
   echo "<div style='margin:5px'></div>\n";
   echo "<table cellpadding='0' cellspacing='1' width='400' class='center tbl-border'>\n<tr>\n";
   echo "<td class='tbl2'><strong>".$locale['401']."</strong></td>\n";
   echo "</tr>\n<tr>\n";
   echo "<td class='tbl1'>\n";
   $user_groups = (strpos($user_data['user_groups'], ".") == 0 ? explode(".", substr($user_data['user_groups'], 1)) : explode(".", $user_data['user_groups']));
   for ($i = 0; $i < count($user_groups); $i++) {
      echo "<div style='float:left'><a href='".FUSION_SELF."?group_id=".$user_groups[$i]."'>".getgroupname($user_groups[$i])."</a></div><div style='float:right'>".getgroupname($user_groups[$i], true)."</div><div style='float:none;clear:both'></div>\n";
   }
   echo "</td>\n</tr>\n</table>\n";
}


And here you will see the selection of the remaining user groups:
$result = dbquery("SELECT * FROM ".DB_USER_GROUPS." ORDER BY group_id ASC");
if (dbrows($result)) {
   while ($data2 = dbarray($result)) {
      if (!preg_match("(^\.{$data2['group_id']}|\.{$data2['group_id']}\.|\.{$data2['group_id']}$)", $user_data['user_groups'])) {
         $user_groups_opts .= "<option value='".$data2['group_id']."'>".$data2['group_name']."</option>\n";
      }
   }
   if (iADMIN && checkrights("UG") && $user_groups_opts) {
      echo "<td align='right' class='tbl1'>".$locale['415']."\n";
      echo "<select name='user_group' class='textbox' style='width:100px'>\n".$user_groups_opts."</select>\n";
      echo "<input type='submit' name='add_to_group' value='".$locale['416']."' class='button'  onclick=\"return confirm('".$locale['417']."');\" /></td>\n";
   }
}


The next piece of code makes that the selection not let see id=1 if user group id=10 allready is assigned to the user:
if (!preg_match("(^\.{$data2['group_id']}|\.{$data2['group_id']}\.|\.{$data2['group_id']}$)", $user_data['user_groups'])) {
   $user_groups_opts .= "<option value='".$data2['group_id']."'>".$data2['group_name']."</option>\n";
}


I hope I'm clear enough.
0 replies
W
WEC
W
WEC 10
  • Veteran Member, joined since
  • Contributed 946 posts on the community forums.
  • Started 5 threads in the forums
answered
Veteran Member

Sorry, didn't note from the subject that it was in profile.php you have the problem.

The code you post is not from v. 7.01.01, so which version do you run?

Any modifications to your profile.php?
0 replies
W
WEC
W
WEC 10
  • Veteran Member, joined since
  • Contributed 946 posts on the community forums.
  • Started 5 threads in the forums
answered
Veteran Member

The bug at least is present in versions 7.00.07 to 7.01.01.

In profile.php find:

if (!preg_match("(^\.{$data2['group_id']}|\.{$data2['group_id']}\.|\.{$data2['group_id']}$)", $user_data['user_groups'])) {


Replace with:

if (!preg_match("(^{$data2['group_id']}|\.{$data2['group_id']}\.|\.{$data2['group_id']}$)", $user_data['user_groups'])) {
0 replies
B
bvcweb
B
bvcweb 10
  • Newbie, joined since
  • Contributed 7 posts on the community forums.
  • Started 3 threads in the forums
  • Started this discussions
answered
Newbie

Hello WEC,

Thnx! This is the solution. My first selection is back on screen so I can choose it.

I'm using v7.00.07 and I have a small modification, but not to this line.
Before I've asked for help I looked at SVN for Profile.php so that I have the original (v7.00.xx and v7.01.xx). Both versions have this problem.

Grtz

<!--Subject close-->
0 replies

Labels

None yet

Statistics

  • Views 0 views
  • Posts 5 posts
  • Votes 0 votes
  • Topic users 2 members

2 participants

W
W
WEC 10
  • Veteran Member, joined since
  • Contributed 946 posts on the community forums.
  • Started 5 threads in the forums
B
B
bvcweb 10
  • Newbie, joined since
  • Contributed 7 posts on the community forums.
  • Started 3 threads in the forums
  • Started this discussions

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet