/** * Assign the user to a group * * @param Entity\UserGroup $group * @return void */ public function setGroup(UserGroup $group) { $this->group = $group; // The association must be defined in both directions if (!$group->getUsers()->contains($this)) { $group->addUser($this); } }
<?php if (isset($_GET['userGroupID'])) { $userGroupID = $_GET['userGroupID']; } else { $userGroupID = ''; } $userGroup = new UserGroup(new NamedArguments(array('primaryKey' => $userGroupID))); //get all users for output in drop down $allUserArray = array(); $userObj = new User(); $allUserArray = $userObj->allAsArray(); //get users already set up for this user group in case it's an edit $ugUserArray = $userGroup->getUsers(); ?> <div id='div_userGroupForm'> <form id='userGroupForm'> <input type='hidden' name='editUserGroupID' id='editUserGroupID' value='<?php echo $userGroupID; ?> '> <div class='formTitle' style='width:280px; margin-bottom:5px;position:relative;'><span class='headerText'><?php if ($userGroupID) { echo _("Edit User Group"); } else { echo _("Add User Group"); } ?> </span></div>
</th> <th><?php echo _("Users"); ?> </th> <th> </th> <th> </th> </tr> <?php foreach ($userGroupArray as $ug) { $userGroup = new UserGroup(new NamedArguments(array('primaryKey' => $ug['userGroupID']))); echo "<tr>"; echo "<td>" . $userGroup->groupName . "</td>"; echo "<td>" . $userGroup->emailAddress . "</td>"; echo "<td>"; foreach ($userGroup->getUsers() as $groupUser) { echo $groupUser->getDisplayName . "<br />"; } echo "</td>"; echo "<td><a href='ajax_forms.php?action=getAdminUserGroupForm&userGroupID=" . $userGroup->userGroupID . "&height=400&width=305&modal=true' class='thickbox'><img src='images/edit.gif' alt='" . _("edit") . "' title='" . _("edit") . "'></a></td>"; echo "<td><a href='javascript:deleteWorkflow(\"UserGroup\", " . $userGroup->userGroupID . ");'><img src='images/cross.gif' alt='" . _("remove") . "' title='" . _("remove") . "'></a></td>"; echo "</tr>"; } ?> </table> <?php } else { echo _("(none found)") . "<br />"; } echo "<a href='ajax_forms.php?action=getAdminUserGroupForm&userGroupID=&height=400&width=305&modal=true' class='thickbox'>" . _("add user group") . "</a>"; ?>