public static function delete_groups() { if (Auth::check()) { $id = $_POST['id']; if (isset($id)) { $strpos = strpos($id, ","); if ($strpos === false) { $ob = new Group($id); $ob->delete(); echo "ok"; } else { $array_id = explode(",", $id); $ob = null; foreach ($array_id as $value) { $ob = new Group($value); $ob->delete(); } echo "ok"; } } else { echo "Error while contacting server, please try again"; } } else { $redirection = Config::get('app.base_url') . Config::get('panel.route') . "/users"; header("Location: {$redirection}"); } }
/** * @todo Implement testDelete(). */ public function testDelete() { $this->object->setName('testgroup'); $this->object->save(); $this->object->delete(); $this->assertEquals(new Group(), new Group($this->object->getId())); }
public function delete() { $Group = new Group($this->data->id); $Group->delete(); $go = '>auth/Group/formFind'; $this->renderPrompt('information', "Group [{$this->data->idGroup}] removido.", $go); }
public static function destroy($group_id) { self::checkLoggedIn(); self::verifyRightsforDeletingOrEditingGroup($group_id); Group::delete($group_id); Redirect::to('/', array('message' => 'Ryhmä poistettu onnistuneesti')); }
function delete($id = FALSE) { if ($id) { $group = new Group($id); $group->delete(); set_notify('success', lang('delete_data_complete')); } redirect('groups/admin/groups'); }
public function delete_group($group_id = NULL) { if (is_null($group_id)) { add_error_flash_message('Skupina sa nenašla.'); redirect(site_url('groups')); } $this->db->trans_begin(); $group = new Group(); $persons_count = $group->person; $persons_count->select_func('COUNT', array('@id'), 'persons_count'); $persons_count->where_related_group('id', '${parent}.id'); $group->select_subquery($persons_count, 'persons_count'); $group->select('*'); $group->get_by_id((int) $group_id); if (!$group->exists()) { $this->db->trans_rollback(); add_error_flash_message('Skupina sa nenašla.'); redirect(site_url('groups')); } if ((int) $group->persons_count > 0) { $this->db->trans_rollback(); add_error_flash_message('Nie je možné vymazať skupinu, ktorá má členov.'); redirect(site_url('groups')); } $success_message = 'Skupina <strong>' . $group->title . '</strong> s ID <strong>' . $group->id . '</strong> bola vymazaná úspešne.'; $error_message = 'Skupinu <strong>' . $group->title . '</strong> s ID <strong>' . $group->id . '</strong> sa nepodarilo vymazať.'; if ($group->delete() && $this->db->trans_status()) { $this->db->trans_commit(); add_success_flash_message($success_message); } else { $this->db->trans_rollback(); add_error_flash_message($error_message); } redirect(site_url('groups')); }
if ($newID = $group->add($_POST)) { Event::log($newID, "groups", 4, "setup", sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], $_POST["name"])); if ($_SESSION['glpibackcreated']) { Html::redirect($group->getFormURL() . "?id=" . $newID); } } Html::back(); } else { if (isset($_POST["purge"])) { $group->check($_POST["id"], PURGE); if ($group->isUsed() && empty($_POST["forcepurge"])) { Html::header($group->getTypeName(1), $_SERVER['PHP_SELF'], "admin", "group", str_replace('glpi_', '', $group->getTable())); $group->showDeleteConfirmForm($_SERVER['PHP_SELF']); Html::footer(); } else { $group->delete($_POST, 1); Event::log($_POST["id"], "groups", 4, "setup", sprintf(__('%s purges an item'), $_SESSION["glpiname"])); $group->redirectToList(); } } else { if (isset($_POST["update"])) { $group->check($_POST["id"], UPDATE); $group->update($_POST); Event::log($_POST["id"], "groups", 4, "setup", sprintf(__('%s updates an item'), $_SESSION["glpiname"])); Html::back(); } else { if (isset($_GET['_in_modal'])) { Html::popHeader(Group::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF']); $group->showForm($_GET["id"]); Html::popFooter(); } else {
define('ROOT', '../..'); include ROOT . '/lib/includeForAjax.php'; requireStrictRoute(); $response = array(); $response['error'] = 0; $response['message'] = ''; $id = $_POST['id']; if(empty($id)) { $response['error'] = -1; $response['message'] = _t('잘못된 접근입니다.'); } else { if (!isAdmin()) { $response['error'] = 1; $response['message'] = _t('관리자만이 이 기능을 사용할 수 있습니다.'); } else { requireComponent('Bloglounge.Data.Groups'); if(!Group::delete($id)) { $response['error'] = 2; $response['message'] = _t('그룹삭제를 실패하였습니다.'); } else { $response['message'] = $name; } } } func::printRespond($response); ?>
$stype = ''; $ltype = 'group'; $title = _T("Delete group", "dyngroup"); $popup = _T("Are you sure you want to delete group <b>%s</b>?<br/> (it can be used in an other group).", "dyngroup"); $delete = _T("Delete group", "dyngroup"); } if (quickGet('valid')) { if ($type == 1) { // Imaging group if (in_array("imaging", $_SESSION["modulesList"])) { // Get Current Location include 'modules/imaging/includes/xmlrpc.inc.php'; $location = xmlrpc_getProfileLocation($id); } } $group->delete(); if ($type == 1) { // Imaging group if (in_array("imaging", $_SESSION["modulesList"])) { // Synchro Location xmlrpc_synchroLocation($location); } header("Location: " . urlStrRedirect("imaging/manage/list{$stype}")); new NotifyWidgetSuccess(sprintf(_T("Imaging group %s was successfully deleted", "imaging"), $group->getName())); } else { // simple group header("Location: " . urlStrRedirect("base/computers/list{$stype}")); new NotifyWidgetSuccess(sprintf(_T("Group %s was successfully deleted", "imaging"), $group->getName())); } exit; }
function removeGroup() { global $tool, $propertyForm; $groupID = $_POST['groupID']; $delSuccess; $curGroup = new Group($groupID); if ($curGroup->delete()) { $delSuccess = true; } else { $delSuccess = false; $error = $curGroupr->get_error(); break; } if ($delSuccess) { $status = "success"; echo "<script language='javascript'>LoadPage(\"configurations.php?action=groupManage&mode=edit&delete=" . $status . "\", 'settingsInfo');</script>"; } else { $propertyForm->error("Warning: Failed to remove group. Reason: " . $error, $_GET['ID']); } }
/** * Build and return admin interface * * Any module providing an admin interface is required to have this function, which * returns a string containing the (x)html of it's admin interface. * @return string */ function getAdminInterface() { $this->template = 'admin/user.tpl'; $this->addJS('/modules/User/js/admin.js'); if (!$this->user->hasPerm('viewusermodule')) { return false; } switch (@$_REQUEST['section']) { case 'deleteUser': $user = new User($_REQUEST['id']); $user->delete(); $this->setupMainList(); $this->template = 'admin/user.tpl'; break; case 'deleteGroup': $group = new Group($_REQUEST['id']); $group->delete(); $groups = Group::getGroups(); $this->smarty->assign('groups', $groups); return $this->smarty->fetch('admin/groups.tpl'); break; case 'groups': $this->template = 'admin/groups.tpl'; $groups = Group::getGroups(); $this->smarty->assign('groups', $groups); break; case 'groupsaddedit': $form = Group::getAddEditForm(); if ($form->validate() && $form->isSubmitted() && isset($_REQUEST['submit'])) { $groups = Group::getGroups(); $this->smarty->assign('groups', $groups); return $this->smarty->fetch('admin/groups.tpl'); } else { return $form->display(); } break; case 'permissions': if (isset($_REQUEST['perm']) && isset($_REQUEST['group'])) { $group = new Group($_REQUEST['group']); $group->togglePerm($_REQUEST['perm']); } if (is_numeric(@$_REQUEST['group_view'])) { $groups = array(); $groups[] = new Group($_REQUEST['group_view']); $groupsView = Group::getGroups(); $this->smarty->assign('selectedGroup', $_REQUEST['group_view']); } else { $groups = Group::getGroups(); $groupsView = $groups; $this->smarty->assign('selectedGroup', null); } $this->template = 'admin/permissions.tpl'; $permissions = Permission::getPermissions(); $this->smarty->assign('permissions', $permissions); $this->smarty->assign('groups', $groups); $this->smarty->assign('groupsView', $groupsView); break; case 'userTable': $this->setupMainList(); $this->template = 'admin/user_table.tpl'; break; case 'addedit': $form = $this->getUserAddEditForm('/admin/User', true); if ($form->validate() && $form->isSubmitted() && (isset($_REQUEST['a_submit']) || isset($_REQUEST['a_cancel']))) { $this->setupMainList(); return $this->smarty->fetch('admin/user.tpl'); } else { return $form->display(); } break; default: $this->setupMainList(); break; } return $this->smarty->fetch($this->template); }
public function testAccessingUsersGroupsAfterGroupIsDeleted() { $user = UserTestHelper::createBasicUser('Dood1'); $group = new Group(); $group->name = 'Doods'; $group->users->add($user); $this->assertTrue($group->save()); $this->assertEquals(1, count($user->groups)); $this->assertEquals('Doods', $user->groups[0]->name); $group->delete(); unset($group); // The user object in memory doesn't // know yet that the group was deleted. $this->assertEquals(1, count($user->groups)); // But in using the app it would be a later // request that would be getting the user // object anew. $user->forget(); unset($user); $user = User::getByUsername('dood1'); // Which shows the group having been deleted. $this->assertEquals(0, count($user->groups)); }
/** * Remove Role From Group * Removes a role from a group * * @param mixed $group_id * @param mixed $role_id */ public function remove_role_from_group($group_id, $role_id) { $g = new Group($group_id); $r = new Role($role_id); if ($g->exists() and $r->exists()) { $g->delete($r); } }
/** * delete group from system with all it's users and all related data * * @param integer $id the group needed to be deleted */ public function deleteGroup($id) { $group = new Group($id); $group->delete(); redirect('users_editor'); }
fAuthorization::requireLoggedIn(); fRequest::overrideAction(); $action = fRequest::getValid('action', array('list', 'add', 'edit', 'delete')); $breadcrumbs[] = array('name' => 'Groups', 'url' => Group::makeURL('list'), 'active' => true); $group_id = fRequest::get('group_id', 'integer'); if ('delete' == $action) { if ($group_id == $GLOBALS['DEFAULT_GROUP_ID']) { fURL::redirect(Group::makeUrl('list')); } else { $class_name = 'Group'; try { $obj = new Group($group_id); $delete_text = 'Are you sure you want to delete the group : <strong>' . $obj->getName() . '</strong>?'; if (fRequest::isPost()) { fRequest::validateCSRFToken(fRequest::get('token')); $obj->delete(); fMessaging::create('success', "/" . Group::makeUrl('list'), 'The group "' . $obj->getName() . '" was successfully deleted'); fURL::redirect(Group::makeUrl('list')); } } catch (fNotFoundException $e) { fMessaging::create('error', "/" . Group::makeUrl('list'), 'The group requested could not be found'); fURL::redirect(Group::makeUrl('list')); } catch (fExpectedException $e) { fMessaging::create('error', fURL::get(), $e->getMessage()); } include VIEW_PATH . '/delete.php'; } // --------------------------------- // } elseif ('edit' == $action) { if ($group_id == $GLOBALS['DEFAULT_GROUP_ID']) { fURL::redirect(Group::makeUrl('list'));
<?php // include the class include 'class/class.group.php'; // instantiate the class $G = new Group(); // delete a record if (isset($_GET['d'])) { $id = $_GET['d']; return $G->delete($id); }
<?php require_once "util.php"; $group = new Group(); if ($action == "new") { $group->create(var_post("group_id", ""), array(var_post("group_name", ""))); } elseif ($action == "edit") { $group->update(var_post("group_id", ""), array(var_post("group_name", ""))); } elseif ($action == "delete") { $group->delete(var_get("group_id", "")); } $group_box = new NTKVBox("group_box", 0, 0, False); $label = new NTKLabel("group_label", "<h3>Gruppen</h3>"); $group_box->add($label); $group_list = $group->get(''); for ($i = 0; $i < count($group_list); $i++) { $group_box->add(new NTKEGroup($group_list[$i][0], $group_list[$i][1])); } $label = new NTKLabel("group_label", "<h4>neue Gruppe</h4>"); $group_box->add($label); $group_box->add(new NTKEGroup("", "", True), -1); $main_box->add($group_box, -1, -1, "background-color: #dfe7f3; vertical-align: top;");
/** * Function: destroy_group * Destroys a group. */ public function destroy_group() { if (!Visitor::current()->group->can("delete_group")) { show_403(__("Access Denied"), __("You do not have sufficient privileges to delete groups.")); } if (!isset($_POST['id'])) { error(__("No ID Specified"), __("An ID is required to delete a group.")); } if ($_POST['destroy'] == "bollocks") { redirect("/admin/?action=manage_groups"); } if (!isset($_POST['hash']) or $_POST['hash'] != Config::current()->secure_hashkey) { show_403(__("Access Denied"), __("Invalid security key.")); } $group = new Group($_POST['id']); foreach ($group->users as $user) { $user->update($user->login, $user->password, $user->email, $user->full_name, $user->website, $_POST['move_group']); } $config = Config::current(); if (!empty($_POST['default_group'])) { $config->set("default_group", $_POST['default_group']); } if (!empty($_POST['guest_group'])) { $config->set("guest_group", $_POST['guest_group']); } Group::delete($_POST['id']); Flash::notice(__("Group deleted."), "/admin/?action=manage_groups"); }
/** * Remove Relationships */ function remove_relationships() { echo '<h1>Remove Relationship</h1>'; echo '<p>Here we get an existing Group object and view its current relations.</p>'; echo '<code> // Get Group 2<br /> $g = new Group();<br /> $g->where(\'id\', 2)->get();</code>'; // Get Group $g = new Group(); $g->where('id', 2)->get(); echo '<hr />'; echo '<p>Now lets loop through and see what users are related.</p>'; echo '<code> // Get related users<br /> $g->user->get();<br /> <br /> // Show User relations for Group 2<br /> foreach ($g->user->all as $u)<br /> {<br /> echo "<p>" . $u->username . " is related to " . $g->name . ".</p>";<br /> }</code>'; // Get related users $g->user->get(); if (empty($g->user->all)) { echo '<p><b>No Relationships</b></p>'; die('<p>Run <a href="' . site_url('examples/add_relationships') . '">Add Relationships</a> to add the relations.</p>'); } else { // Show User relations for Group 2 foreach ($g->user->all as $u) { echo '<p>' . $u->username . ' is related to ' . $g->name . '.</p>'; } } echo '<hr />'; echo '<p>Now we\'ll delete the relations.</p>'; echo '<code> // Remove relations from Group 2<br /> $g->delete($g->user->all);</code>'; // Remove relations from Group 2 $g->delete($g->user->all); echo '<hr />'; echo '<p>If we check the related users again, it will be empty.</p>'; echo '<code> // Check relations<br /> if (empty($g->user->all))<br /> {<br /> echo "<p>No users are related to the " . $g->name . " group.</p>";<br /> }</code>'; // Check relations<br /> if (empty($g->user->all)) { echo "<p> No users are related to the " . $g->name . " group.</p>"; } else { // Show User relations for Group 2 foreach ($g->user->all as $u) { echo '<p>' . $u->username . ' is related to ' . $g->name . '.</p>'; } } echo '<p>Run <a href="' . site_url('examples/add_relationships') . '">Add Relationships</a> to add the relations back in.</p>'; echo '<p><a href="' . site_url('examples') . '">Back to Examples</a></p>'; }
public function delete() { $this->output->set_content_type('application/json'); $uri = $this->uri->ruri_to_assoc(3); if (isset($uri['group_id'])) { $this->_transaction_isolation(); $this->db->trans_begin(); $group = new Group(); $group->get_by_id(intval($uri['group_id'])); $course_id = $group->course_id; if ($group->exists()) { $group->room->get()->delete_all(); $group->delete(); if ($this->db->trans_status()) { $this->db->trans_commit(); $this->output->set_output(json_encode(TRUE)); $this->_action_success(); $this->output->set_internal_value('course_id', $course_id); } else { $this->db->trans_rollback(); $this->output->set_output(json_encode(FALSE)); } } else { $this->db->trans_rollback(); $this->output->set_output(json_encode(FALSE)); } } else { $this->output->set_output(json_encode(FALSE)); } }
/** * @throws GroupIDMissingException */ public static function delete() { if ($_GET['id']) { $group_id = $_GET['id']; $group = new Group($group_id); if ($_GET['sure'] != "true") { $template = new HTMLTemplate("base/user/admin/group/delete.html"); $paramquery = $_GET; $paramquery['sure'] = "true"; $params = http_build_query($paramquery); $template->set_var("yes_params", $params); $paramquery = $_GET; unset($paramquery['sure']); unset($paramquery['action']); unset($paramquery['id']); $params = http_build_query($paramquery, '', '&'); $template->set_var("no_params", $params); $template->output(); } else { $paramquery = $_GET; unset($paramquery['sure']); unset($paramquery['action']); unset($paramquery['id']); $params = http_build_query($paramquery, '', '&'); if ($group->delete()) { Common_IO::step_proceed($params, "Delete Group", "Operation Successful", null); } else { Common_IO::step_proceed($params, "Delete Group", "Operation Failed", null); } } } else { throw new GroupIDMissingException(); } }
public static function deleteGroup(Group $group) { Rating::where("[entityId] = ? AND [entityType] = ?", [$group->id, Group::ENTITY_TYPE])->delete(); RatingStatistic::where("[entityId] = ? AND [entityType] = ?", [$group->id, Group::ENTITY_TYPE])->delete(); Counter::where("[entityId] = ? AND [entityTypeId] = ?", [$group->id, Group::ENTITY_TYPE])->delete(); $topics = Topic::find("groupId", $group->id)->all(); foreach ($topics as $topic) { $topic->delete(); } GroupUser::where("[groupId] = ?", $group->id)->delete(); $group->delete(); }
if (empty($_GET["id"])) { $_GET["id"] = ""; } $group = new Group(); $groupuser = new Group_User(); if (isset($_POST["add"])) { $group->check(-1, 'w', $_POST); if ($newID = $group->add($_POST)) { Event::log($newID, "groups", 4, "setup", sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], $_POST["name"])); } Ajax::refreshDropdownPopupInMainWindow(); Html::back(); } else { if (isset($_POST["delete"])) { $group->check($_POST["id"], 'd'); $group->delete($_POST); Event::log($_POST["id"], "groups", 4, "setup", sprintf(__('%s purges an item'), $_SESSION["glpiname"])); $group->redirectToList(); } else { if (isset($_POST["update"])) { $group->check($_POST["id"], 'w'); $group->update($_POST); Event::log($_POST["id"], "groups", 4, "setup", sprintf(__('%s updates an item'), $_SESSION["glpiname"])); Html::back(); } else { if (isset($_GET['popup'])) { Html::popHeader(Group::getTypeName(2), $_SERVER['PHP_SELF']); if (isset($_GET["rand"])) { $_SESSION["glpipopup"]["rand"] = $_GET["rand"]; } $group->showForm($_GET["id"]);
/** * Create admin page * * @author Thibaud Rohmer */ public function __construct() { /// Check that current user is an admin or an uploader if (!(CurrentUser::$admin || CurrentUser::$uploader)) { return; } /// Get actions available for Uploaders too if (isset($_GET['a'])) { switch ($_GET['a']) { case "Abo": $this->page = new AdminAbout(); break; case "Upl": if (isset($_POST['path'])) { AdminUpload::upload(); CurrentUser::$path = File::r2a(stripslashes($_POST['path'])); } break; case "Mov": if (isset($_POST['pathFrom'])) { try { CurrentUser::$path = File::r2a(dirname(stripslashes($_POST['pathFrom']))); } catch (Exception $e) { CurrentUser::$path = Settings::$photos_dir; } } Admin::move(); if (isset($_POST['move']) && $_POST['move'] == "rename") { try { if (is_dir(File::r2a(stripslashes($_POST['pathFrom'])))) { CurrentUser::$path = dirname(File::r2a(stripslashes($_POST['pathFrom']))) . "/" . stripslashes($_POST['pathTo']); } } catch (Exception $e) { CurrentUser::$path = Settings::$photos_dir; } } break; case "Del": if (isset($_POST['del'])) { if (!is_array($_POST['del'])) { CurrentUser::$path = dirname(File::r2a(stripslashes($_POST['del']))); } else { CurrentUser::$path = dirname(File::r2a(stripslashes($_POST['del'][0]))); } Admin::delete(); } break; } } /// Check that current user is an admin if (!CurrentUser::$admin) { return; } /// Get action if (isset($_GET['a'])) { switch ($_GET['a']) { case "Sta": $this->page = new AdminStats(); break; case "VTk": $this->page = new GuestToken(); break; case "DTk": if (isset($_POST['tokenkey'])) { GuestToken::delete($_POST['tokenkey']); } $this->page = new GuestToken(); break; case "Acc": if (isset($_POST['edit'])) { Account::edit($_POST['login'], $_POST['old_password'], $_POST['password'], $_POST['name'], $_POST['email'], NULL, $_POST['language']); } if (isset($_POST['login'])) { $this->page = new Account($_POST['login']); } else { $this->page = CurrentUser::$account; } break; case "GC": Group::create($_POST['group']); $this->page = new Group(); break; case "AAc": Account::create($_POST['login'], $_POST['password'], $_POST['verif']); $this->page = new Group(); break; case "AGA": $a = new Account($_POST['acc']); $a->add_group($_POST['group']); $a->save(); $this->page = CurrentUser::$account; break; case "AGR": $a = new Account($_POST['acc']); $a->remove_group($_POST['group']); $a->save(); $this->page = CurrentUser::$account; break; case "ADe": Account::delete($_POST['name']); $this->page = new Group(); break; case "GEd": Group::edit($_POST); $this->page = new Group(); break; case "GDe": Group::delete($_GET['g']); $this->page = new Group(); break; case "CDe": CurrentUser::$path = File::r2a($_POST['image']); Comments::delete($_POST['id']); $this->page = new MainPage(); break; case "JS": break; case "EdA": $this->page = new Group(); break; case "GAl": if (isset($_POST['path'])) { Settings::gener_all(File::r2a(stripslashes($_POST['path']))); } case "Set": if (isset($_POST['name'])) { Settings::set(); } $this->page = new Settings(); break; } } if (!isset($this->page)) { $this->page = new AdminAbout(); } /// Create menu $this->menu = new AdminMenu(); }
/** * Delete a group. Requires login and user must be an admin for the group. * * @param string $groupid * @return Result or Error */ function deleteGroup($groupid) { $g = new Group($groupid); $result = $g->delete(); return $result; }
} // disable the user profile if ($action == 'disableUser') { $user = new User(); $user->storeFormValues($_GET); $user->status(); } // delete the user profile if ($action == 'deleteUser') { $user = new User(); $user->storeFormValues($_GET); $user->delete(); } // enable the group if ($action == 'enableGroup') { $user = new Group(); $user->storeFormValues($_GET); $user->status(); } // disable the group if ($action == 'disableGroup') { $user = new Group(); $user->storeFormValues($_GET); $user->status(); } // delete the group if ($action == 'deleteGroup') { $user = new Group(); $user->storeFormValues($_GET); $user->delete(); }