isAdmin()) { UI::exitError(getMLText("admin_tools"),getMLText("access_denied")); } if (isset($_POST["action"])) $action = $_POST["action"]; else $action = null; // Create new group -------------------------------------------------------- if ($action == "addgroup") { /* Check if the form data comes for a trusted request */ if(!checkFormKey('addgroup')) { UI::exitError(getMLText("admin_tools"),getMLText("invalid_request_token")); } $name = $_POST["name"]; $comment = $_POST["comment"]; if (is_object($dms->getAttributeDefinitionGroupByName($name))) { UI::exitError(getMLText("admin_tools"),getMLText("group_exists")); } $newGroup = $dms->addAttributeDefinitionGroup($name, $comment); if (!$newGroup) { UI::exitError(getMLText("admin_tools"),getMLText("error_occured")); } $groupid=$newGroup->getID(); $session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_add_group'))); add_log_line("&action=addgroup&name=".$name); } // Delete group ------------------------------------------------------------- else if ($action == "removegroup") { /* Check if the form data comes for a trusted request */ if(!checkFormKey('removegroup')) { UI::exitError(getMLText("admin_tools"),getMLText("invalid_request_token")); } if (!isset($_POST["attrdefgroupid"]) || !is_numeric($_POST["attrdefgroupid"]) || intval($_POST["attrdefgroupid"])<1) { UI::exitError(getMLText("admin_tools"),getMLText("invalid_group_id")); } $group = $dms->getAttributeDefinitionGroup($_POST["attrdefgroupid"]); if (!is_object($group)) { UI::exitError(getMLText("admin_tools"),getMLText("invalid_group_id")); } if (!$group->remove($user)) { UI::exitError(getMLText("admin_tools"),getMLText("error_occured")); } $groupid = ''; $session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_rm_group'))); add_log_line("?attrdefgroupid=".$_POST["attrdefgroupid"]."&action=removegroup"); } // Modifiy group ------------------------------------------------------------ else if ($action == "editgroup") { /* Check if the form data comes for a trusted request */ if(!checkFormKey('editgroup')) { UI::exitError(getMLText("admin_tools"),getMLText("invalid_request_token")); } if (!isset($_POST["attrdefgroupid"]) || !is_numeric($_POST["attrdefgroupid"]) || intval($_POST["attrdefgroupid"])<1) { UI::exitError(getMLText("admin_tools"),getMLText("invalid_group_id")); } $groupid=$_POST["attrdefgroupid"]; $group = $dms->getAttributeDefinitionGroup($groupid); if (!is_object($group)) { UI::exitError(getMLText("admin_tools"),getMLText("invalid_group_id")); } $name = $_POST["name"]; $comment = $_POST["comment"]; if ($group->getName() != $name) $group->setName($name); if ($group->getComment() != $comment) $group->setComment($comment); $session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_edit_group'))); add_log_line("?attrdefgroupid=".$_POST["attrdefgroupid"]."&action=editgroup"); } // Add user to group -------------------------------------------------------- else if ($action == "addmember") { /* Check if the form data comes for a trusted request */ if(!checkFormKey('addmember')) { UI::exitError(getMLText("admin_tools"),getMLText("invalid_request_token")); } if (!isset($_POST["attrdefgroupid"]) || !is_numeric($_POST["attrdefgroupid"]) || intval($_POST["attrdefgroupid"])<1) { UI::exitError(getMLText("admin_tools"),getMLText("invalid_group_id")); } $groupid=$_POST["attrdefgroupid"]; $group = $dms->getAttributeDefinitionGroup($groupid); if (!is_object($group)) { UI::exitError(getMLText("admin_tools"),getMLText("invalid_group_id")); } if (!isset($_POST["attrdefid"]) || !is_numeric($_POST["attrdefid"]) || intval($_POST["attrdefid"])<1) { UI::exitError(getMLText("admin_tools"),getMLText("invalid_user_id")); } $newMember = $dms->getAttributeDefinition($_POST["attrdefid"]); if (!is_object($newMember)) { UI::exitError(getMLText("admin_tools"),getMLText("invalid_user_id")); } $show = 0; foreach($_POST['shows'] as $s) { $show += $s; } if (!$group->isMember($newMember)){ $group->addAttributeDefinition($newMember, $show); } $session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_add_group_member'))); add_log_line("?attrdefgroupid=".$groupid."&attrdefid=".$_POST["attrdefid"]."&action=addmember"); } // Remove attribute definition from group -------------------------------------------------- else if ($action == "rmmember") { /* Check if the form data comes for a trusted request */ if(!checkFormKey('rmmember')) { UI::exitError(getMLText("admin_tools"),getMLText("invalid_request_token")); } if (!isset($_POST["attrdefgroupid"]) || !is_numeric($_POST["attrdefgroupid"]) || intval($_POST["attrdefgroupid"])<1) { UI::exitError(getMLText("admin_tools"),getMLText("invalid_group_id")); } $groupid=$_POST["attrdefgroupid"]; $group = $dms->getAttributeDefinitionGroup($groupid); if (!is_object($group)) { UI::exitError(getMLText("admin_tools"),getMLText("invalid_group_id")); } if (!isset($_POST["attrdefid"]) || !is_numeric($_POST["attrdefid"]) || intval($_POST["attrdefid"])<1) { UI::exitError(getMLText("admin_tools"),getMLText("invalid_user_id")); } $oldMember = $dms->getAttributeDefinition($_POST["attrdefid"]); if (!is_object($oldMember)) { UI::exitError(getMLText("admin_tools"),getMLText("invalid_user_id")); } $group->removeAttributeDefinition($oldMember); $session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_rm_group_member'))); add_log_line("?attrdefgroupid=".$groupid."&attrdefid=".$_POST["attrdefid"]."&action=rmmember"); } // Set sequence of member of group -------------------------------------------------- else if ($action == "setsequence") { /* Check if the form data comes for a trusted request */ if(!checkFormKey('setsequence')) { UI::exitError(getMLText("admin_tools"),getMLText("invalid_request_token")); } if (!isset($_POST["attrdefgroupid"]) || !is_numeric($_POST["attrdefgroupid"]) || intval($_POST["attrdefgroupid"])<1) { UI::exitError(getMLText("admin_tools"),getMLText("invalid_group_id")); } $groupid=$_POST["attrdefgroupid"]; $group = $dms->getAttributeDefinitionGroup($groupid); if (!is_object($group)) { UI::exitError(getMLText("admin_tools"),getMLText("invalid_group_id")); } if (!isset($_POST["attrdefid"]) || !is_numeric($_POST["attrdefid"]) || intval($_POST["attrdefid"])<1) { UI::exitError(getMLText("admin_tools"),getMLText("invalid_user_id")); } $member = $dms->getAttributeDefinition($_POST["attrdefid"]); if (!is_object($member)) { UI::exitError(getMLText("admin_tools"),getMLText("invalid_user_id")); } $group->setSequence($member, $_POST['sequence']); $session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_set_group_sequence'))); add_log_line("?attrdefgroupid=".$groupid."&attrdefid=".$_POST["attrdefid"]."&action=setsequence"); } // Set show of member of group -------------------------------------------------- else if ($action == "setshow") { /* Check if the form data comes for a trusted request */ if(!checkFormKey('setshow')) { UI::exitError(getMLText("admin_tools"),getMLText("invalid_request_token")); } if (!isset($_POST["attrdefgroupid"]) || !is_numeric($_POST["attrdefgroupid"]) || intval($_POST["attrdefgroupid"])<1) { UI::exitError(getMLText("admin_tools"),getMLText("invalid_group_id")); } $groupid=$_POST["attrdefgroupid"]; $group = $dms->getAttributeDefinitionGroup($groupid); if (!is_object($group)) { UI::exitError(getMLText("admin_tools"),getMLText("invalid_group_id")); } if (!isset($_POST["attrdefid"]) || !is_numeric($_POST["attrdefid"]) || intval($_POST["attrdefid"])<1) { UI::exitError(getMLText("admin_tools"),getMLText("invalid_user_id")); } $member = $dms->getAttributeDefinition($_POST["attrdefid"]); if (!is_object($member)) { UI::exitError(getMLText("admin_tools"),getMLText("invalid_user_id")); } $show = 0; foreach($_POST['shows'] as $s) { $show += $s; } $group->setShow($member, $show); $session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_set_group_show'))); add_log_line("?attrdefgroupid=".$groupid."&attrdefid=".$_POST["attrdefid"]."&action=setshow"); } header("Location:../out/out.AttributeGroupMgr.php?attrdefgroupid=".$groupid); ?>