Skip to content

Commit

Permalink
Merge pull request benedmunds#1462 from kgkanatsios/edit-user-code-re…
Browse files Browse the repository at this point in the history
…factoring

User Edit: Code refactoring
  • Loading branch information
benedmunds authored Jul 23, 2020
2 parents cca1882 + 4a9b7f8 commit 491d0d2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
2 changes: 1 addition & 1 deletion controllers/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ public function edit_user($id)

$user = $this->ion_auth->user($id)->row();
$groups = $this->ion_auth->groups()->result_array();
$currentGroups = $this->ion_auth->get_users_groups($id)->result();
$currentGroups = $this->ion_auth->get_users_groups($id)->result_array();

//USAGE NOTE - you can do more complicated queries like this
//$groups = $this->ion_auth->where(['field' => 'value'])->groups()->result_array();
Expand Down
13 changes: 1 addition & 12 deletions views/auth/edit_user.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,7 @@
<h3><?php echo lang('edit_user_groups_heading');?></h3>
<?php foreach ($groups as $group):?>
<label class="checkbox">
<?php
$gID=$group['id'];
$checked = null;
$item = null;
foreach($currentGroups as $grp) {
if ($gID == $grp->id) {
$checked= ' checked="checked"';
break;
}
}
?>
<input type="checkbox" name="groups[]" value="<?php echo $group['id'];?>"<?php echo $checked;?>>
<input type="checkbox" name="groups[]" value="<?php echo $group['id'];?>" <?php echo (in_array($group, $currentGroups)) ? 'checked="checked"' : null; ?>>
<?php echo htmlspecialchars($group['name'],ENT_QUOTES,'UTF-8');?>
</label>
<?php endforeach?>
Expand Down

0 comments on commit 491d0d2

Please sign in to comment.