public static function update($id)
 {
     self::check_logged_in();
     $params = $_POST;
     $attributes = array('id' => $id, 'name' => $params['name']);
     $group = new Group($attributes);
     $errors = $group->errors();
     if (count($errors) > 0) {
         View::make('group/edit.html', array('errors' => $errors, 'attributes' => $attributes));
     } else {
         $group->update();
         Redirect::to('/group/' . $group->id, array('message' => 'Ryhmää muokattu onnistuneesti'));
     }
 }
 public static function update($group_id)
 {
     self::checkLoggedIn();
     self::verifyRightsforDeletingOrEditingGroup($group_id);
     $params = $_POST;
     $group = new Group(array('name' => $params['name'], 'id' => $params['id']));
     $errors = $group->errors();
     $message;
     if (count($errors) == 0) {
         $group->update();
         $message = array('message' => 'Ryhmän nimi vaihdettu onnistuneesti');
     } else {
         $message = array('errors' => $errors);
     }
     Redirect::to('/groups/' . $group_id . '/edit', $message);
 }
Example #3
0
function editGroup()
{
    global $lang;
    $page_lang = scandir('inc/lang/' . $_SESSION['language']);
    foreach ($page_lang as $file) {
        if ($file != '.' && $file != '..') {
            $parts = explode(".", $file);
            $page = $parts[0];
            if ($page == 'group') {
                $page_file = $file;
            }
        }
    }
    include_once 'inc/lang/' . $_SESSION['language'] . '/' . $page_file;
    if ($_SESSION['access']->users > 1) {
        $results = array();
        $results['formAction'] = "editGroup";
        if (isset($_POST['saveChanges'])) {
            // User has posted the group edit form: save the group changes
            if (!($group = Group::getById((int) $_GET['editId']))) {
                header("Location: index.php?action=listUser&error=groupNotFound");
                return;
            }
            $group = new Group();
            $group->storeFormValues($_POST);
            $group->update();
            header("Location: index.php?action=listUser&success=groupChangesSaved");
        } elseif (isset($_POST['cancel'])) {
            // User has cancelled their edits: return to the group list
            header("Location: index.php?action=listUser");
        } else {
            // User has not submitted the group edit form: display the group edit form
            $results['group'] = Group::getById((int) $_GET['groupId']);
            require "inc/layout/editGroup.php";
        }
    } else {
        require "inc/layout/noAccess.php";
    }
}
Example #4
0
                         $msg="$num of $count selected topics deleted!";
                     else
                         $errors['err']='Unable to delete selected topics';
                 }
             }
             break;
         default:
             $errors['err']='Unknown topic action!';
     }
     break;
 case 'groups':
     include_once(INCLUDE_DIR.'class.group.php');
     $do=strtolower($_POST['do']);
     switch($do){
         case 'update':
             if(Group::update($_POST['group_id'],$_POST,$errors)){
                 $msg='Group '.Format::htmlchars($_POST['group_name']).' updated successfully';
             }elseif(!$errors['err']) {
                 $errors['err']='Error(s) occured. Try again.';
             }
             break;
         case 'create':
             if(($gID=Group::create($_POST,$errors))){
                 $msg='Group '.Format::htmlchars($_POST['group_name']).' created successfully';
             }elseif(!$errors['err']) {
                 $errors['err']='Error(s) occured. Try again.';
             }
             break;
         default:
             //ok..at this point..look WMA.
             if($_POST['grps'] && is_array($_POST['grps'])) {
Example #5
0
File: Admin.php Project: eadz/chyrp
 /**
  * Function: update_group
  * Updates a group when the form is submitted.
  */
 public function update_group()
 {
     if (!Visitor::current()->group->can("edit_group")) {
         show_403(__("Access Denied"), __("You do not have sufficient privileges to edit groups."));
     }
     if (!isset($_POST['hash']) or $_POST['hash'] != Config::current()->secure_hashkey) {
         show_403(__("Access Denied"), __("Invalid security key."));
     }
     $permissions = array_keys($_POST['permissions']);
     $check_name = new Group(null, array("where" => array("name" => $_POST['name'], "id not" => $_POST['id'])));
     if (!$check_name->no_results) {
         Flash::notice(_f("Group name “%s” is already in use.", array($_POST['name'])), "/admin/?action=edit_group&id=" . $_POST['id']);
     }
     $group = new Group($_POST['id']);
     if ($group->no_results) {
         Flash::warning(__("Group not found."), "/admin/?action=manage_groups");
     }
     $group->update($_POST['name'], $permissions);
     Flash::notice(__("Group updated."), "/admin/?action=manage_groups");
 }
Example #6
0
 */
require_once __DIR__ . '/../../init.php';
$tpl = new Template_Helper();
$tpl->setTemplate('manage/groups.tpl.html');
Auth::checkAuthentication();
$role_id = Auth::getCurrentRole();
if ($role_id < User::ROLE_MANAGER) {
    Misc::setMessage(ev_gettext('Sorry, you are not allowed to access this page.'), Misc::MSG_ERROR);
    $tpl->displayTemplate();
    exit;
}
if (@$_POST['cat'] == 'new') {
    $res = Group::insert();
    Misc::mapMessages($res, array(1 => array(ev_gettext('Thank you, the group was added successfully.'), Misc::MSG_INFO), -1 => array(ev_gettext('An error occurred while trying to add the new group.'), Misc::MSG_ERROR)));
} elseif (@$_POST['cat'] == 'update') {
    $res = Group::update();
    Misc::mapMessages($res, array(1 => array(ev_gettext('Thank you, the group was updated successfully.'), Misc::MSG_INFO), -1 => array(ev_gettext('An error occurred while trying to update the group.'), Misc::MSG_ERROR)));
} elseif (@$_POST['cat'] == 'delete') {
    Group::remove();
}
if (@$_GET['cat'] == 'edit') {
    $info = Group::getDetails($_GET['id']);
    $tpl->assign('info', $info);
    $user_options = User::getActiveAssocList(Auth::getCurrentProject(), User::ROLE_CUSTOMER, false, $_GET['id']);
} else {
    $user_options = User::getActiveAssocList(Auth::getCurrentProject(), User::ROLE_CUSTOMER, true);
}
if (@$_GET['show_customers'] == 1) {
    $show_customer = true;
} else {
    $show_customer = false;
<?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;");
Example #8
0
} 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 {
                if (isset($_POST["replace"])) {
                    $group->check($_POST["id"], PURGE);
                    $group->delete($_POST, 1);
                    Event::log($_POST["id"], "groups", 4, "setup", sprintf(__('%s replaces an item'), $_SESSION["glpiname"]));
                    $group->redirectToList();
                } else {
                    Html::header(Group::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "admin", "group");
<!DOCTYPE html>

<?php 
include 'class/class.group.php';
$G = new Group();
$id = $_GET['u'];
// get single
$group = $G->Single($id);
if (isset($_POST['update'])) {
    $label_name = $_POST['label_name'];
    $id = $_POST['id'];
    $update = $G->update($id, $label_name);
    // if update is succesful
    if ($update == 1) {
        // add the id and an update variable of 1
        header("Location:updateGroup.php?u={$id}&update=1");
    }
}
?>

<html>
  <head>
  <title>SMSAPP | Update Contacts</title>
  <?php 
include "includes/_metaheader.php";
?>
  <?php 
include "includes/_csslinks.php";
?>
  </head>
  <body class="hold-transition skin-blue sidebar-mini">
echo '<p>The "' . $group->name . '" have ID = ' . $id . '.</p>';
$group->reset();
// deletes all information in the object
$group->name = 'Beautiful Group';
$group->date = '20050412';
$group->insert();
// let's not get the ID here, it's already set
echo '<p>The "' . $group->name . '" have ID = ' . $group->id . '.</p>';
$group->reset();
$group->name = 'Yo! Ugly Group';
$group->date = '19001231';
$group->insert();
echo '<p>The "' . $group->name . '" have ID = ' . $group->id . '.</p>';
echo "<p>Oops... it's not " . substr($group->date, 0, 4) . " but 1999. Let's <b>update</b> it.</p>";
$group->date = '19991231';
$group->update();
echo "<p>Now we have the correct year: " . substr($group->date, 0, 4) . ".</p>";
$group->reset();
echo "<h1>Let's find the groups starting with Y</h1>";
$group->addWhere("name LIKE 'Y%'");
$group->addOrder("id");
$total = $group->find();
echo "<p>We've found " . $total . " groups starting with Y.</p>";
// we can use the count method to get the same result
if ($group->count() > 1) {
    while ($group->fetch()) {
        YDDebugUtil::dump($group->getValues());
    }
}
echo "<h1>But I really want is the first group.</h1>";
$group->reset();
Example #11
0
include_once APP_INC_PATH . "class.group.php";
include_once APP_INC_PATH . "class.project.php";
include_once APP_INC_PATH . "db_access.php";
$tpl = new Template_API();
$tpl->setTemplate("manage/index.tpl.html");
Auth::checkAuthentication(APP_COOKIE);
$tpl->assign("type", "groups");
$role_id = Auth::getCurrentRole();
if ($role_id == User::getRoleID('administrator') || $role_id == User::getRoleID('manager')) {
    if ($role_id == User::getRoleID('administrator')) {
        $tpl->assign("show_setup_links", true);
    }
    if (@$HTTP_POST_VARS["cat"] == "new") {
        $tpl->assign("result", Group::insert());
    } elseif (@$HTTP_POST_VARS["cat"] == "update") {
        $tpl->assign("result", Group::update());
    } elseif (@$HTTP_POST_VARS["cat"] == "delete") {
        Group::remove();
    }
    if (@$HTTP_GET_VARS["cat"] == "edit") {
        $info = Group::getDetails($HTTP_GET_VARS["id"]);
        $tpl->assign("info", $info);
    }
    $user_options = User::getActiveAssocList(false, NULL, false, false, true);
    if (@$HTTP_GET_VARS['show_customers'] == 1) {
        $show_customer = true;
    } else {
        $show_customer = false;
    }
    $tpl->assign("user_options", $user_options);
    $tpl->assign("list", Group::getList());
Example #12
0
function updateGroup()
{
    global $tool, $propertyForm;
    $newGroup = new Group($_POST['id']);
    $tempInfo = array();
    print_r($_POST);
    $key = array("name", "desc", "access", "ldap", "group_pass");
    foreach ($key as $index => $key) {
        $tempInfo[$key] = htmlspecialchars(trim($_POST[$key]), ENT_QUOTES);
    }
    //add slashes to these 2 to make sure it does not display wrongly
    $tempInfo[name] = addslashes($tempInfo[name]);
    $tempInfo[desc] = addslashes($tempInfo[desc]);
    //checks if the name is empty, if not set all the names and insert them
    if ($newGroup->set_name($tempInfo[name])) {
        //set all the values to the query
        $newGroup->set_description($tempInfo[desc]);
        $newGroup->set_access_level($tempInfo[access]);
        $newGroup->set_ldap_group_name($tempInfo[ldap]);
        $newGroup->set_group_pass($tempInfo[group_pass]);
        //if the insert is sucessful reload the page with the new values
        if ($newGroup->update()) {
            $status = "success";
            echo "<script language='javascript'>LoadPage(\"configurations.php?action=groupManage&mode=edit&update=" . $status . "\", 'settingsInfo');</script>";
            //echo "<meta http-equiv=\"REFRESH\" content=\"0;url=".$_SERVER['PHP_SELF']."?action=userManage&add=$status\">";
        } else {
            $propertyForm->error("Warning: Failed to update group. Reason: " . $newGroup->get_error(), $_GET['ID']);
        }
    } else {
        $propertyForm->error("Warning: Failed to update group. Reason: " . $newGroup->get_error(), $_GET['ID']);
    }
}