예제 #1
0
 public function run()
 {
     $groups = [["id" => 1, "name" => "ADMIN"], ["id" => 2, "name" => "USUARIO"]];
     foreach ($groups as $group) {
         Group::create($group);
     }
 }
 /**
  * @throws ValidationException
  * @throws null
  */
 public function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     /**
      * Add default site admin group if none with
      * permission code SITE_ADMIN exists
      *
      * @var Group $siteAdminGroup
      */
     $siteAdminGroups = DataObject::get('Group')->filter(array('Code' => 'site-administrators'));
     if (!$siteAdminGroups->count()) {
         $siteAdminGroup = Group::create();
         $siteAdminGroup->Code = 'site-administrators';
         $siteAdminGroup->Title = _t('BoilerplateGroupExtension.SiteAdminGroupTitle', 'Site Administrators');
         $siteAdminGroup->Sort = 0;
         $siteAdminGroup->write();
         /** Default CMS permissions */
         Permission::grant($siteAdminGroup->ID, 'CMS_ACCESS_LeftAndMain');
         Permission::grant($siteAdminGroup->ID, 'SITETREE_VIEW_ALL');
         Permission::grant($siteAdminGroup->ID, 'SITETREE_EDIT_ALL');
         Permission::grant($siteAdminGroup->ID, 'SITETREE_REORGANISE');
         Permission::grant($siteAdminGroup->ID, 'VIEW_DRAFT_CONTENT');
         Permission::grant($siteAdminGroup->ID, 'SITETREE_GRANT_ACCESS');
         Permission::grant($siteAdminGroup->ID, 'EDIT_SITECONFIG');
     }
 }
예제 #3
0
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Group::create(['name' => $faker->randomDigit]);
     }
 }
예제 #4
0
 public function Register($data, Form $form)
 {
     if (!Member::currentUser()) {
         $member = new Member();
         // Debug::show($form);
         $form->saveInto($member);
         if (Group::get()->filter('Title', 'Subscribed')->count() == 0) {
             $group = Group::create();
             $group->Title = 'Subscribed';
             $group->write();
         } else {
             $group = Group::get()->filter('Title', 'Subscribed')->First();
         }
         if (Member::get()->filter('Email', $data['Email'])) {
             $form->addErrorMessage('Email', 'That email address is already in use. <a href="Security/login">login</a>', 'bad', true, true);
             //Controller::curr()->redirect('register');
         } else {
             //has to be called before setting group
             $member->write();
             if (!$member->inGroup($group)) {
                 $member->Groups()->add($group);
             }
         }
     }
     Controller::curr()->redirectBack();
 }
예제 #5
0
 function create($page = NULL)
 {
     //load block submit helper and append in the head
     $this->template->append_metadata(block_submit_button());
     //create control variables
     $this->template->title(lang('web_add_group'));
     $this->template->set('updType', 'create');
     $this->template->set('page', $this->uri->segment(4) ? $this->uri->segment(4) : $this->input->post('page', TRUE));
     //Rules for validation
     $this->set_rules();
     //validate the fields of form
     if ($this->form_validation->run() == FALSE) {
         //load the view
         $this->template->build('groups/create');
     } else {
         //Validation OK!
         $form_data = array('name' => set_value('name'), 'description' => set_value('description'));
         $group = Group::create($form_data);
         if ($group->is_valid()) {
             $this->session->set_flashdata('message', array('type' => 'success', 'text' => lang('web_create_success')));
         }
         if ($group->is_invalid()) {
             $this->session->set_flashdata('message', array('type' => 'error', 'text' => $group->errors->full_messages()));
         }
         redirect('/admin/groups/');
     }
 }
예제 #6
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('groups')->delete();
     Group::create(array('name' => 'Megacities'));
     Group::create(array('name' => 'House, mouse ...'));
     Group::create(array('name' => 'Last year'));
 }
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Group::create([]);
     }
 }
예제 #8
0
 public function post_index()
 {
     $group = array('name' => Input::get('name'), 'description' => Input::get('description'));
     $new_group = Group::create($group);
     if ($new_group) {
         return Redirect::to_action('groups');
     }
 }
 protected function setUp()
 {
     $grp = new Group();
     $grp->destroy();
     for ($i = 0; $i < 10; $i++) {
         $grp->create(array("title" => "title" . $i, "memo" => "memomemo"));
         $grp->save();
     }
 }
예제 #10
0
 /**
  * Store a newly created group in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make($data = Input::all(), Group::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     Group::create($data);
     return Redirect::route('groups.index');
 }
예제 #11
0
 public function testAdminUser()
 {
     $user = User::create(array('username' => 'testuser'));
     $user->save();
     $group = Group::create(array('name' => 'An admin group', 'is_admin' => true));
     $user->groups()->attach($group->id);
     $article = new Article();
     $article->body = 'can you access this?';
     $article->save();
     $this->assertTrue($this->redoubt->userCan('edit', $article, $user));
 }
 /**
  * @param string$code
  * @param null|string $title
  * @param null|string $description
  * @return ISecurityGroup
  */
 public function build($code, $title = null, $description = null)
 {
     $group = Group::create();
     $group->Code = $code;
     if (is_null($title)) {
         $title = ucfirst($code);
     }
     $group->Title = $title;
     if (!is_null($description)) {
         $group->Description = $description;
     }
     return $group;
 }
 function doUp()
 {
     global $database;
     if (intval(Group::get()->filter('Code', 'SUMMIT_FRONT_END_ADMINISTRATORS')->count()) > 0) {
         return;
     }
     $g = Group::create();
     $g->setTitle('Summit Front End Administrators');
     $g->setDescription('Allows to Access to summit-admin application');
     $g->setSlug('SUMMIT_FRONT_END_ADMINISTRATORS');
     $g->write();
     Permission::grant($g->getIdentifier(), 'ADMIN_SUMMIT_APP_FRONTEND_ADMIN');
 }
 public function run()
 {
     if (Group::count('id')) {
         echo 'Skipping group seeder' . "\n";
         return;
     }
     $groups = [['title' => 'Ожидающий доступа', 'configs' => ['stars' => 0, 'title' => 'Ожидающий доступа', 'conf_show_signature' => false]], ['title' => 'Администратор', 'configs' => ['title' => 'Администратор']], ['title' => 'Newbie', 'configs' => ['stars' => 0, 'title' => 'Ньюбл', 'conf_show_signature' => false]], ['title' => 'Junior', 'configs' => ['stars' => 1, 'title' => 'Юниор']], ['title' => 'Member', 'configs' => ['stars' => 2, 'title' => 'Участник']], ['title' => 'Full Member', 'configs' => ['stars' => 3, 'title' => 'Уверенный пользователь']], ['title' => 'Senior Member', 'configs' => ['stars' => 4, 'title' => 'Сеньор']], ['title' => 'Profi', 'configs' => ['stars' => 5, 'title' => 'Профи']], ['title' => 'Master', 'configs' => ['stars' => 6, 'title' => 'Мастер']], ['title' => 'Guru', 'configs' => ['stars' => 7, 'title' => 'Гуру']], ['title' => 'Monster', 'configs' => ['stars' => 8, 'title' => 'Монстр']], ['title' => 'Wizard', 'configs' => ['stars' => 9, 'title' => 'Волшебник']], ['title' => 'God', 'configs' => ['stars' => 10, 'title' => 'Бог']], ['title' => 'Нарушившие правила', 'configs' => ['title' => 'Нарушитель', 'conf_show_signature' => false]], ['title' => 'Бан', 'configs' => ['title' => 'В бане', 'conf_show_signature' => false]], ['title' => 'Комодератор', 'configs' => ['title' => 'Помошник модератора']], ['title' => 'Модератор', 'configs' => ['title' => 'Модератор']], ['title' => 'Супермодератор', 'configs' => ['title' => 'Супермод']], ['title' => 'Ветеран', 'configs' => ['title' => 'Ветеран']], ['title' => 'Участники клуба Sources.RU', 'configs' => ['title' => 'Клубень']]];
     DB::transaction(function () use($groups) {
         foreach ($groups as $group) {
             Group::create($group);
         }
     });
 }
예제 #15
0
 /**
  * Create a new group
  */
 public function storeAction()
 {
     $validation = Validator::make(Input::all(), Group::$rules);
     if (!$validation->passes()) {
         return Redirect::route('groups.create')->withInput()->withErrors($validation)->with('message', 'There were validation errors.');
     }
     /**
      * Check name duplicates
      */
     if (count(Group::where('name', Input::get('name'))->get())) {
         return Redirect::route('groups.create')->withInput()->with('message', 'This group already exists.');
     }
     $group = Group::create(Input::all());
     return Redirect::route('groups.show', $group->id);
 }
예제 #16
0
 public function run()
 {
     #DB::table('groups')->truncate();
     Group::create(array('name' => 'developer', 'desc' => 'Разработчики', 'dashboard' => 'admin'));
     Group::create(array('name' => 'admin', 'desc' => 'Администраторы', 'dashboard' => 'admin'));
     Group::create(array('name' => 'doctors', 'desc' => 'Доктора', 'dashboard' => 'doctors'));
     ## SELECT CONCAT("['module' => '", module, "', 'action' => '", action, "'],") FROM `actions` WHERE 1
     $actions = [['module' => 'system', 'action' => 'system'], ['module' => 'system', 'action' => 'settings'], ['module' => 'system', 'action' => 'modules'], ['module' => 'system', 'action' => 'groups'], ['module' => 'system', 'action' => 'users'], ['module' => 'system', 'action' => 'locale_editor']];
     if (isset($actions) && is_array($actions) && count($actions)) {
         foreach ($actions as $act) {
             if (!is_array($act) || !isset($act['module']) || !$act['module'] || !isset($act['action']) || !$act['action']) {
                 continue;
             }
             Action::create(array('group_id' => '1', 'module' => $act['module'], 'action' => $act['action'], 'status' => '1'));
         }
     }
 }
예제 #17
0
 public function run()
 {
     #DB::table('groups')->truncate();
     Group::create(array('name' => 'developer', 'desc' => 'Разработчики', 'dashboard' => 'admin'));
     Group::create(array('name' => 'admin', 'desc' => 'Администраторы', 'dashboard' => 'admin'));
     Group::create(array('name' => 'moderator', 'desc' => 'Модераторы', 'dashboard' => 'admin'));
     ## SELECT CONCAT("['module' => '", module, "', 'action' => '", action, "'],") FROM `actions` WHERE 1
     $actions = [['module' => 'dictionaries', 'action' => 'view'], ['module' => 'dictionaries', 'action' => 'create'], ['module' => 'dictionaries', 'action' => 'edit'], ['module' => 'dictionaries', 'action' => 'delete'], ['module' => 'dictionaries', 'action' => 'dicval_view'], ['module' => 'dictionaries', 'action' => 'dicval_create'], ['module' => 'dictionaries', 'action' => 'dicval_edit'], ['module' => 'dictionaries', 'action' => 'dicval_delete'], ['module' => 'dictionaries', 'action' => 'dicval_restore'], ['module' => 'dictionaries', 'action' => 'settings'], ['module' => 'dictionaries', 'action' => 'dicval_entity_view'], ['module' => 'dictionaries', 'action' => 'hidden'], ['module' => 'dictionaries', 'action' => 'import'], ['module' => 'galleries', 'action' => 'view'], ['module' => 'galleries', 'action' => 'create'], ['module' => 'galleries', 'action' => 'edit'], ['module' => 'galleries', 'action' => 'delete'], ['module' => 'pages', 'action' => 'view'], ['module' => 'pages', 'action' => 'create'], ['module' => 'pages', 'action' => 'edit'], ['module' => 'pages', 'action' => 'delete'], ['module' => 'pages', 'action' => 'advanced'], ['module' => 'pages', 'action' => 'page_restore'], ['module' => 'seo', 'action' => 'edit'], ['module' => 'system', 'action' => 'system'], ['module' => 'system', 'action' => 'settings'], ['module' => 'system', 'action' => 'modules'], ['module' => 'system', 'action' => 'groups'], ['module' => 'system', 'action' => 'users'], ['module' => 'system', 'action' => 'locale_editor']];
     if (isset($actions) && is_array($actions) && count($actions)) {
         foreach ($actions as $act) {
             if (!is_array($act) || !isset($act['module']) || !$act['module'] || !isset($act['action']) || !$act['action']) {
                 continue;
             }
             Action::create(array('group_id' => '1', 'module' => $act['module'], 'action' => $act['action'], 'status' => '1'));
         }
     }
 }
 /**
  * @param $data
  * @param $form
  * @return bool|SS_HTTPResponse
  */
 public function Register($data, $form)
 {
     /** @var Form $form */
     $data = $form->getData();
     /** Set session array individually as setting the password breaks the form. */
     $sessionArray = array('Email' => $data['Email']);
     /** Check for existing member email address */
     if ($existingUser = DataObject::get_one('Member', "Email = '" . Convert::raw2sql($data['Email']) . "'")) {
         $form->AddErrorMessage('Email', 'Sorry, that email address already exists. Please choose another.', 'validation');
         Session::set('FormInfo.Form_' . $this->name . '.data', $sessionArray);
         return $this->controller->redirectBack();
     }
     /** Otherwise create new member and log them in
      *
      * @var Member $member
      */
     $member = Member::create();
     $form->saveInto($member);
     $member->write();
     $member->login();
     /** Find or create the 'user' group
      *
      * @var Group $userGroup
      */
     if (!($userGroup = DataObject::get_one('Group', "Code = 'users'"))) {
         $userGroup = Group::create();
         $userGroup->Code = 'users';
         $userGroup->Title = 'Users';
         $userGroup->Write();
         $userGroup->Members()->add($member);
     }
     /** Add member to user group */
     $userGroup->Members()->add($member);
     /** Get profile page otherwise display warning. */
     if ($ProfilePage = DataObject::get_one('EditProfilePage')) {
         $this->controller->setFlash('Welcome ' . $data['Email'] . ', your account has been created!', 'success');
         return $this->controller->redirect($ProfilePage->Link());
     } else {
         $this->controller->setFlash('Please add a "Edit Profile Page" in your SiteTree to enable profile editing', 'warning');
         return $this->controller->redirect(Director::absoluteBaseURL());
     }
 }
 public function postStore()
 {
     Allow::permission($this->module['group'], 'groups');
     $json_request = array('status' => FALSE, 'responseText' => '', 'responseErrorText' => '', 'redirect' => FALSE);
     $input = array('name' => mb_strtolower(Input::get('name')), 'desc' => Input::get('desc'), 'dashboard' => Input::get('dashboard'));
     $validation = Validator::make($input, Group::$rules);
     if ($validation->passes()) {
         Group::create($input);
         #return link::auth('groups');
         $json_request['responseText'] = "Группа &laquo;" . $input['desc'] . "&raquo; создана";
         #$json_request['responseText'] = print_r(Input::get('actions'), 1);
         $json_request['redirect'] = link::auth('system/groups');
         $json_request['status'] = TRUE;
     } else {
         #return Response::json($v->messages()->toJson(), 400);
         $json_request['responseText'] = 'Неверно заполнены поля';
         $json_request['responseErrorText'] = implode($validation->messages()->all(), '<br />');
     }
     return Response::json($json_request, 200);
 }
예제 #20
0
파일: group.php 프로젝트: fendela/ftm
// Prüfen ob bereits ein Turnier gewählt wurde
if (isset($_SESSION['TournamentId']) && !empty($_SESSION['TournamentId'])) {
    echo "<hr /><br />SESSIONS: ", sizeof($_SESSION), "<br />";
    foreach ($_SESSION as $key => $value) {
        echo $key, " => ", $value, "<br />";
    }
    echo "<hr /><br />POSTS: ", sizeof($_POST), "<br />";
    foreach ($_POST as $key => $value) {
        echo $key, " => ", $value, "<br />";
    }
    echo "<hr />";
    if (isset($_POST['newGroup'])) {
        echo "CREATE GROUP";
        include 'class_group.php';
        $group = new Group();
        if ($group->create()) {
            echo "SESSION SET <br />";
            $_SESSION['GroupId'] = $group->getId();
            echo "GroupsS <br />";
            print_r($group->getAllGroups());
        } else {
            echo "CREATE ERROR";
        }
    }
}
?>
<form action="group.php" method="post">
<table>
	<tr><td>Gruppe: </td><td><input type="text" name="name" /></td></tr>
	<tr><td>Teams: </td><td><input type="text" name="teamcount" /></td></tr>
	<tr><td>Runde: </td><td><input type="text" name="round" /></td></tr>
예제 #21
0
 public function run()
 {
     Group::create(array('uid' => 'testgroup', 'name' => 'Test Workgroup', 'about' => 'This is a test workgroup', 'ownerid' => 1, 'private' => false, 'members' => serialize(array(1)), 'boards' => serialize(array()), 'files' => serialize(array())));
 }
예제 #22
0
파일: Control.php 프로젝트: Max201/nanocore
 /**
  * Create new group
  *
  * @param Request $request
  * @param $matches
  * @return mixed|string
  */
 public function group_create(Request $request, $matches)
 {
     \GroupPermission::updatePermissionsList();
     $perms = \GroupPermission::defaultMap();
     if ($request->isMethod('post')) {
         // Saving permissions
         foreach ($perms as $key => $val) {
             $new_val = $request->get('perm_' . $key) == 'true';
             $perms[$key] = $new_val;
         }
         $data = ['name' => $request->get('name'), 'icon' => $request->get('icon')];
         $group = \Group::create($data);
         if ($group) {
             /** @var \Permission $gperms */
             $gperms = $group->getPermissions();
             $gperms->exchangeArray($perms);
             $gperms->save();
             return static::json_response(['status' => $this->lang->translate('form.saved'), 'class' => 'success']);
         } else {
             return static::json_response(['status' => $this->lang->translate('form.failed'), 'class' => 'error']);
         }
     }
     return $this->view->render('users/group_create.twig', ['title' => $this->lang->translate('user.group.create'), 'perms' => $perms]);
 }
예제 #23
0
파일: admin.php 프로젝트: hungnv0789/vhtm
             $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'])) {
                 $ids=implode(',',$_POST['grps']);
                 $selected=count($_POST['grps']);
                 if(isset($_POST['activate_grps'])) {
                     $sql='UPDATE '.GROUP_TABLE.' SET group_enabled=1,updated=NOW() WHERE group_enabled=0 AND group_id IN('.$ids.')';
                     db_query($sql);
                     $msg=db_affected_rows()." of  $selected selected groups Enabled";
                 }elseif(in_array($thisuser->getDeptId(),$_POST['grps'])) {
        $changes = new stdClass();
        $changes->name = $name;
        $changes->owner = $owner_id;
        $changes->description = $description;
        $changes->title = $title;
        $changes->address = $address;
        $changes->postcode = $postcode;
        $changes->city = $city;
        $changes->stateorprovince = $stateorprovince;
        $changes->country = $country;
        $changes->voicetelephone = $voicetelephone;
        $changes->facsimiletelephone = $facsimiletelephone;
        $changes->email = $email;
        $changes->logo_path = $logo_path;
        $group->change($changes);
        $group->create();
        $selected_group = $group->getId();
    }
}
#update
if ($action == 'update') {
    $group = Group::byName($name);
    if (!is_null($group) && intval($group->getId()) !== intval($selected_group)) {
        echo "<script type='text/javascript'>alert('Groupname must be unique!');</script>";
    } else {
        $group = new Group(intval($selected_group));
        $changes = new stdClass();
        $changes->name = $name;
        $changes->owner = $owner_id;
        $changes->description = $description;
        $changes->title = $title;
예제 #25
0
 public static function create()
 {
     if ($_GET['nextpage'] == 1) {
         $page_1_passed = true;
         if ($_POST['name']) {
             if (Group::exist_name($_POST['name']) == true) {
                 $page_1_passed = false;
                 $error = "This groupname already exists";
             }
         } else {
             $page_1_passed = false;
             $error = "You must enter a groupname";
         }
     } else {
         $page_1_passed = false;
         $error = "";
     }
     if ($page_1_passed == false) {
         $template = new HTMLTemplate("base/user/admin/group/add.html");
         $paramquery = $_GET;
         $paramquery['nextpage'] = "1";
         $params = http_build_query($paramquery, '', '&#38;');
         $template->set_var("params", $params);
         if ($error) {
             $template->set_var("error", $error);
         } else {
             $template->set_var("error", "");
         }
         if ($_POST['name']) {
             $template->set_var("name", $_POST['name']);
         } else {
             $template->set_var("name", "");
         }
         $template->output();
     } else {
         $paramquery = $_GET;
         unset($paramquery['nextpage']);
         unset($paramquery['action']);
         $params = http_build_query($paramquery);
         $group = new Group($_POST['group']);
         $paramquery = $_GET;
         unset($paramquery['action']);
         unset($paramquery['nextpage']);
         $params = http_build_query($paramquery, '', '&#38;');
         if ($group->create($_POST['name'])) {
             Common_IO::step_proceed($params, "Add Group", "Operation Successful", null);
         } else {
             Common_IO::step_proceed($params, "Add Group", "Operation Failed", null);
         }
     }
 }
예제 #26
0
function displayLogs($params)
{
    $result1 = xmlCall('msc.displayLogs', array($params));
    if (!empty($_GET['create_group'])) {
        // Small hack to include all pages
        $params['min'] = 0;
        $params['max'] = 9999999;
        $result = xmlCall('msc.displayLogs', array($params));
        require_once "modules/dyngroup/includes/dyngroup.php";
        require_once "modules/dyngroup/includes/xmlrpc.php";
        // Group name
        $cmd_name = $result[1][0][0]['title'];
        $groupname = sprintf(_T("%s deployment subgroup - %s", "msc"), $cmd_name, date("Y-m-d H:i:s"));
        // Creating group with displayLogs result filter
        $coh_ids = array();
        foreach ($result[1] as $entry) {
            $coh_ids[] = $entry[3]['id'];
        }
        $targets = get_targets_for_coh($coh_ids);
        // Adding group members
        $groupmembers = array();
        foreach ($targets as $target) {
            $uuid = $target['target_uuid'];
            $cn = $target['target_name'];
            $groupmembers["{$uuid}##{$cn}"] = array('hostname' => $cn, 'uuid' => $uuid);
        }
        $group = new Group();
        $group->create($groupname, False);
        $group->addMembers($groupmembers);
        $link = urlStrRedirect("base/computers/display", array('gid' => $group->id));
        new NotifyWidgetSuccess(sprintf(_T('Deploy subgroup created successfully. <br/><a href="%s" target="_blank">View group</a>', "msc"), $link));
    }
    return $result1;
}
예제 #27
0
 /**
  * Create group file
  *
  * @return void
  * @author Thibaud Rohmer
  */
 public static function create_group_file()
 {
     $xml = new SimpleXMLElement('<groups></groups>');
     $xml->asXML(CurrentUser::$groups_file);
     Group::create("root");
     Group::create("uploaders");
     Group::create("user");
 }
예제 #28
0
if ($_REQUEST['id'] && !($group = Group::lookup($_REQUEST['id']))) {
    $errors['err'] = sprintf(__('%s: Unknown or invalid ID.'), __('group'));
}
if ($_POST) {
    switch (strtolower($_POST['do'])) {
        case 'update':
            if (!$group) {
                $errors['err'] = sprintf(__('%s: Unknown or invalid'), __('group'));
            } elseif ($group->update($_POST, $errors)) {
                $msg = sprintf(__('Successfully updated %s'), __('this group'));
            } elseif (!$errors['err']) {
                $errors['err'] = sprintf(__('Unable to update %s. Correct error(s) below and try again!'), __('this group'));
            }
            break;
        case 'create':
            if ($id = Group::create($_POST, $errors)) {
                $msg = sprintf(__('Successfully added %s'), Format::htmlchars($_POST['name']));
                $_REQUEST['a'] = null;
            } elseif (!$errors['err']) {
                $errors['err'] = sprintf(__('Unable to add %s. Correct error(s) below and try again.'), __('this group'));
            }
            break;
        case 'mass_process':
            if (!$_POST['ids'] || !is_array($_POST['ids']) || !count($_POST['ids'])) {
                $errors['err'] = sprintf(__('You must select at least %s.'), __('one group'));
            } elseif (in_array($thisstaff->getGroupId(), $_POST['ids'])) {
                $errors['err'] = __("As an admin, you cannot disable/delete a group you belong to - you might lockout all admins!");
            } else {
                $count = count($_POST['ids']);
                switch (strtolower($_POST['a'])) {
                    case 'enable':
예제 #29
0
<?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;");
예제 #30
0
 *
 * You should have received a copy of the GNU General Public License
 * along with MMC; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
require_once "modules/dyngroup/includes/dyngroup.php";
# for Group Class
require_once "modules/glpi/includes/xmlrpc.php";
require_once "modules/dyngroup/includes/xmlrpc.php";
require_once "modules/pulse2/includes/locations_xmlrpc.inc.php";
require_once "modules/base/includes/computers.inc.php";
$requestedOS = $_GET['os'];
// Group name
$groupname = sprintf(_T("Machine with %s installed at %s", "glpi"), $requestedOS, date("Y-m-d H:i:s"));
// Get user locations
$groupmembers = array();
$result = getMachineByOsLike($requestedOS, 0);
foreach ($result as $entry) {
    $uuid = 'UUID' . $entry[0];
    $cn = $entry[1];
    $groupmembers["{$uuid}##{$cn}"] = array('hostname' => $cn, 'uuid' => $uuid);
}
$group = new Group();
$group->create($groupname, False);
$group->addMembers($groupmembers);
$truncate_limit = getMaxElementsForStaticList();
if ($truncate_limit == count($groupmembers)) {
    new NotifyWidgetWarning(sprintf(_T("Computers list has been truncated at %d computers", "dyngroup"), $truncate_limit));
}
header("Location: " . urlStrRedirect("base/computers/display", array('gid' => $group->id)));
exit;