/** * this function shows the form for sending a message to a specific group or user. */ public static function show_to_form_group($group_id) { echo "<table id=\"recipient_list\" >"; echo "<tr>"; echo "<td>"; echo "<select id=\"not_selected_form\" name=\"not_selected_form[]\" size=5 style=\"width:200px\" multiple>"; $group_users = GroupManager::getStudentsAndTutors($group_id); foreach ($group_users as $user) { echo '<option value="' . $user['user_id'] . '" title="' . sprintf(get_lang('LoginX'), $user['username']) . '" >' . api_get_person_name($user['firstname'], $user['lastname']) . '</option>'; } echo '</select>'; echo "</td>"; // the buttons for adding or removing groups/users echo "<td valign=\"middle\">"; echo '<button class="btn btn-default" type="button" onClick="javascript: move(this.form.elements[1], this.form.elements[4])" onClick="javascript: move(this.form.elements[1], this.form.elements[4])"><em class="fa fa-arrow-right"></em></button>'; echo '<br /> <br />'; echo '<button class="btn btn-default" type="button" onClick="javascript: move(this.form.elements[4], this.form.elements[1])" onClick="javascript: move(this.form.elements[4], this.form.elements[1])"><em class="fa fa-arrow-left"></em></button>'; echo "</td>"; echo "<td>"; echo "<select id=\"selectedform\" name=\"selectedform[]\" size=5 style=\"width:200px\" multiple>"; echo '</select>'; echo "</td>"; echo "</tr>"; echo "</table>"; }
/** * Unsubscribe groups to item * @param $tool * @param Course $course * @param Session $session * @param $itemId * @param $groups */ public function unsubscribeGroupsToItem($tool, Course $course, Session $session = null, $itemId, $groups, $unsubscribeUserToo = false) { if (!empty($groups)) { $em = $this->getEntityManager(); foreach ($groups as $groupId) { $item = $this->findOneBy(array('tool' => $tool, 'session' => $session, 'ref' => $itemId, 'group' => $groupId)); if ($item) { $em->remove($item); } if ($unsubscribeUserToo) { //Adding users from this group to the item $users = \GroupManager::getStudentsAndTutors($groupId); $newUserList = array(); if (!empty($users)) { foreach ($users as $user) { $newUserList[] = $user['user_id']; } $this->unsubcribeUsersToItem('learnpath', $course, $session, $itemId, $newUserList); } } } $em->flush(); } }