function updateGroup($id, $request) { $group = loadGroup($id); if (!empty($group)) { DB::statement('UPDATE groups SET name = ?, private = ? WHERE id = ?', [$request->name, $request->type, $group[0]->id]); } }
// Add alerts for any failed input validation foreach ($validator->errors as $error) { addAlert("danger", $error); } if (count($validator->errors) > 0) { apiReturnError($ajax, getReferralPage()); } if ($user_id) { // Special case to load groups for the logged in user if ($user_id == "0") { $user_id = $loggedInUser->user_id; } // Attempt to load group information for the specified user. if (!($results = loadUserGroups($user_id))) { apiReturnError($ajax, getReferralPage()); } } else { if ($group_id) { // Attempt to load information for the specified group. if (!($results = loadGroup($group_id))) { apiReturnError($ajax, getReferralPage()); } } else { // Attempt to load information for all groups if (!($results = loadGroups())) { apiReturnError($ajax, getReferralPage()); } } } restore_error_handler(); echo json_encode($results);
if ($group_id) { $populate_fields = true; $button_submit_text = "Update group"; $target = "update_group.php"; $box_title = "Update group"; } else { $populate_fields = false; $button_submit_text = "Create group"; $target = "create_group.php"; $box_title = "New group"; } $group_name = ""; $home_page_id = ""; // If we're in update mode, load group data if ($populate_fields) { $group = loadGroup($group_id); $group_name = $group['name']; $home_page_id = $group['home_page_id']; } $response = ""; if ($render_mode == "modal") { $response .= "<div id='{$box_id}' class='modal fade'>\n <div class='modal-dialog'>\n <div class='modal-content'>\n <div class='modal-header'>\n <button type='button' class='close' data-dismiss='modal' aria-hidden='true'>×</button>\n <h4 class='modal-title'>{$box_title}</h4>\n </div>\n <div class='modal-body'>\n <form method='post' action='{$target}'>"; } else { if ($render_mode == "panel") { $response .= "<div class='panel panel-primary'>\n <div class='panel-heading'>\n <h2 class='panel-title pull-left'>{$box_title}</h2>\n <div class='clearfix'></div>\n </div>\n <div class='panel-body'>\n <form method='post' action='{$target}'>"; } else { echo "Invalid render mode."; exit; } } // Load CSRF token
private static function buildSystemNotifications($notification) { $string = ""; switch ($notification->type) { case "group request accepted": $groupname = loadGroup($notification->object_id)[0]->name; $group = '<a href=/groups/' . $notification->object_id . '>' . $groupname . '</a>'; $string = (object) array_merge((array) $notification, array('message' => 'Your request to join the group \'' . $group . '\' has been accepted.')); break; case "group request declined": $groupname = loadGroup($notification->object_id)[0]->name; $group = '<a href=/groups/' . $notification->object_id . '>' . $groupname . '</a>'; $string = (object) array_merge((array) $notification, array('message' => 'Your request to join the group \'' . $group . '\' has been declined.')); break; case "series updated": $seriesTitle = loadSerieWithId($notification->object_id)[0]->title; $series = '<a href=/series/' . $notification->object_id . '>' . $seriesTitle . '</a>'; $string = (object) array_merge((array) $notification, array('message' => 'The series \'' . $series . '\' has been updated, check it out!')); break; case "exercise referenced": $series = '<a href=/series/' . $notification->object_id . '>series</a>.'; $string = (object) array_merge((array) $notification, array('message' => 'An exercise of yours was referenced in another ' . $series)); break; case "exercise copied": $series = '<a href=/series/' . $notification->object_id . '>series</a>.'; $string = (object) array_merge((array) $notification, array('message' => 'An exercise of yours was copied to another ' . $series)); break; } return $string; }
<td>Enter Username</td> <td align="right"><input type="text" placeholder="Min 5 characters" id="user" name="user" disabled="true" required><br><span id="usererr"></span></td> </tr> <tr> <td>Enter Password</td> <td align="right"><input type="password" placeholder="Min 8 characters" id="pass" name="pass" required></td> </tr> <tr> <td>Confirm Password</td> <td align="right"><input type="password" id="cpass" placeholder="Repeat Password" name="cpass" required><br><span id="cpasserr"></span></td> </tr> <tr> <td>Select Type</td> <td align="right"><select name="cutype" id="cutype" size="1" required> _END; loadGroup(); echo <<<_END </select><br><br> </td> </tr> <tr> <td align="center" colspan="2"><input type="submit" class="button" value="Create Account"></td> </tr> </center> </table> </form> </div> </div> _END; } else { echo '<br><br><span class="error">Access Denied! You are not authorized to view this section</span>';
public function removeMember($groupId, $userId) { $group = loadGroup($groupId)[0]; if (loadUser($userId)) { declineMemberToGroup($userId, $groupId); //Just the user as "declined" flash()->error('You have kicked the user from your group. They will not be able to request to join your group again.'); return redirect('groups/' . $group->name . '/manageMembers'); } flash()->error('Could not kick member, try again.'); return redirect('groups/' . $group->name . '/manageMembers'); }
$_SESSION["currentpage"] = "Geographytype"; $arrScriptFiles = array("script", "Geographytype.js", "manage_Geographytype.js", "AutoComplete.js", "baseConnection.js", "msgPopup.js", "formPopup.js", "manage_Cookie.js"); $arrStyleFiles = array("style", "styles.css", "Geographytype.css"); array_push($arrFilesForLoad, $arrStyleFiles); array_push($arrFilesForLoad, $arrScriptFiles); loadHeader($arrFilesForLoad); loadGeographytype($_GET); break; case "Group": $_SESSION["currentpage"] = "Group"; $arrScriptFiles = array("script", "Group.js", "manage_Group.js", "AutoComplete.js", "baseConnection.js", "msgPopup.js", "formPopup.js", "manage_Cookie.js"); $arrStyleFiles = array("style", "styles.css", "Group.css"); array_push($arrFilesForLoad, $arrStyleFiles); array_push($arrFilesForLoad, $arrScriptFiles); loadHeader($arrFilesForLoad); loadGroup($_GET); break; case "Group_member": $_SESSION["currentpage"] = "Group_member"; $arrScriptFiles = array("script", "Group_member.js", "manage_Group_member.js", "AutoComplete.js", "baseConnection.js", "msgPopup.js", "formPopup.js", "manage_Cookie.js"); $arrStyleFiles = array("style", "styles.css", "Group_member.css"); array_push($arrFilesForLoad, $arrStyleFiles); array_push($arrFilesForLoad, $arrScriptFiles); loadHeader($arrFilesForLoad); loadGroup_member($_GET); break; case "Groupmissiontype": $_SESSION["currentpage"] = "Groupmissiontype"; $arrScriptFiles = array("script", "Groupmissiontype.js", "manage_Groupmissiontype.js", "AutoComplete.js", "baseConnection.js", "msgPopup.js", "formPopup.js", "manage_Cookie.js"); $arrStyleFiles = array("style", "styles.css", "Groupmissiontype.css"); array_push($arrFilesForLoad, $arrStyleFiles);