public function testPasswordExpiresPolicyRules() { $everyoneGroup = Group::getByName(Group::EVERYONE_GROUP_NAME); $everyoneGroup->save(); $user = UserTestHelper::createBasicUser('Bobby'); $id = $user->id; unset($user); $user = User::getById($id); $adapter = new UserGroupMembershipToViewAdapter($user); $viewData = $adapter->getViewData(); $compareData = array($everyoneGroup->id => array('displayName' => 'Everyone', 'canRemoveFrom' => false)); $this->assertEquals($compareData, $viewData); $a = new Group(); $a->name = 'AAA'; $this->assertTrue($a->save()); $a->users->add($user); $this->assertTrue($a->save()); $user->forget(); $groupId = $a->id; $a->forget(); unset($a); $user = User::getById($id); $adapter = new UserGroupMembershipToViewAdapter($user); $viewData = $adapter->getViewData(); $compareData = array($everyoneGroup->id => array('displayName' => 'Everyone', 'canRemoveFrom' => false), $groupId => array('displayName' => 'AAA', 'canRemoveFrom' => true)); $this->assertEquals($compareData, $viewData); $user->forget(); unset($user); }
public function getIndex() { $action = $_GET['action']; if ($action == "update") { $to = $_GET['to']; $id = $_GET['id']; $groupEntry = Group::find($id); $groupEntry->name = $to; $groupEntry->save(); } else { if ($action == "delete") { $id = $_GET['id']; $groupEntry = Group::find($id); $groupEntry->delete(); } else { if ($action == "insert") { $name = $_GET['name']; $group = new Group(); $group->name = $name; $group->save(); } } } return View::make('admin'); }
/** * Edits an existing user group * * @access public * @return void */ public function editAction() { $this->title = 'Edit user group'; $form = new GroupForm(); $groupModel = new Group(); if ($this->getRequest()->isPost()) { if ($form->isValid($this->getRequest()->getPost())) { $groupModel->save($form->getValues()); $this->_helper->FlashMessenger(array('msg-success' => 'The group was successfully edited.')); App_FlagFlippers_Manager::save(); $this->_redirect('/groups/'); } } else { $id = $this->_getParam('id'); if (!is_numeric($id)) { $this->_helper->FlashMessenger(array('msg-success' => 'The provided group_id is invalid.')); $this->_redirect('/groups/'); } $row = $groupModel->findById($id); if (empty($row)) { $this->_helper->FlashMessenger(array('msg-success' => 'The requested group could not be found.')); $this->_redirect('/groups/'); } $form->populate($row->toArray()); $this->view->item = $row; } $this->view->form = $form; }
public function save() { $Group = new Group($this->data->Group); $Group->save(); $go = '>auth/Group/formObject/' . $Group->getId(); $this->renderPrompt('information', 'OK', $go); }
/** * @api {post} /companies/new Add new company * @apiName Add a new company. * @apiGroup Company * @apiDescription Create new company. * <p>After a new company is created, a company group will be auto generated. * The first member enrolled (actived) into the company group will be the owner of the company group.</p> * <p>If all the information(name, address, city, zip_code, province) provided matches the existing data, * no new record will generate. Instead, the existing company id will return.</p> * @apiParam {String} name company's name. * @apiParam {String} address company's address. * @apiParam {String} country company's country. * @apiParam {String} province company's city. * @apiParam {String} city company's city. * @apiParam {String} zip_code company's zip code. * * @apiError 400 Input Invalid. This will happen if the param is missing or not in the valid format. * @apiError 409 Company name already exist. * @apiSuccessExample {json} Success-Response: * HTTP/1.1 200 OK * { * "name": "New Company", * "address": "123 Test Way", * "country": "United States", * "city": "Chicago", * "zip_code": "60606", * "province": "Illinois", * "id": 19 * } */ public static function addNew() { $app = \Slim\Slim::getInstance(); $data = $app->request->post(); //validate input $validata = $app->validata; $validator = $validata::key('name', $validata::stringType()->notEmpty())->key('address', $validata::stringType()->notEmpty())->key('country', $validata::stringType()->notEmpty())->key('city', $validata::stringType()->notEmpty())->key('zip_code', $validata::stringType()->notEmpty())->key('province', $validata::stringType()->notEmpty()); if (!$validator->validate((array) $data)) { $app->halt(400, json_encode("Input Invalid")); } foreach ($data as $key => $value) { if (!in_array($key, ['name', 'address', 'country', 'city', 'province', 'zip_code'])) { unset($data[$key]); } } if (self::isExist($data['name'])) { $app->halt(409, json_encode("Compnay name already exists")); } $company = Company::firstOrNew($data); if (!$company->id) { $company->save(); $group = new Group(); $group->company_id = $company->id; $group->name = $company->name; $group->access_code = self::generateRandomString(8); $group->save(); } return json_encode($company); }
public function create() { if (!$this->valid_logged_in) { redirect('users/login'); } $this->load->library('form_validation'); if ($this->form_validation->run('groups_create') == FALSE) { $this->load->library('table'); $data['visibility_options'] = $this->visibility_options; // Load group creation form $data['title'] = "Create Group"; $data['content'] = 'groups/create'; $this->load->view('master', $data); } else { // Create group $name = $this->input->post('name'); $description = $this->input->post('description'); $visibility = $this->input->post('visibility'); $group = new Group(); $group->name = $name; $group->description = $description; $group->visibility = $visibility; $user = new User($this->user_id); $group->save($user); redirect("groups/view/{$group->id}"); } }
public static function setUpBeforeClass() { parent::setUpBeforeClass(); AllPermissionsOptimizationUtil::rebuild(); SecurityTestHelper::createSuperAdmin(); $everyoneGroup = Group::getByName(Group::EVERYONE_GROUP_NAME); assert($everyoneGroup->save()); // Not Coding Standard $group1 = new Group(); $group1->name = 'Group1'; assert($group1->save()); // Not Coding Standard $group2 = new Group(); $group2->name = 'Group2'; assert($group2->save()); // Not Coding Standard $group3 = new Group(); $group3->name = 'Group3'; assert($group3->save()); // Not Coding Standard $group4 = new Group(); $group4->name = 'Group4'; assert($group4->save()); // Not Coding Standard }
public static function setUpBeforeClass() { parent::setUpBeforeClass(); SecurityTestHelper::createSuperAdmin(); $super = User::getByUsername('super'); Yii::app()->user->userModel = $super; AllPermissionsOptimizationUtil::rebuild(); //Add the nobody user to an account, but only read only. $nobody = User::getByUsername('nobody'); $account = AccountTestHelper::createAccountByNameForOwner('superAccountReadableByNobody', Yii::app()->user->userModel); $account->addPermissions($nobody, Permission::READ, Permission::ALLOW); assert($account->save()); // Not Coding Standard AllPermissionsOptimizationUtil::securableItemGivenPermissionsForUser($account, $nobody); //Give the nobody user rights to the accounts module. $nobody->setRight('AccountsModule', AccountsModule::RIGHT_ACCESS_ACCOUNTS); $nobody->setRight('AccountsModule', AccountsModule::RIGHT_CREATE_ACCOUNTS); assert($nobody->save()); // Not Coding Standard $everyoneGroup = Group::getByName(Group::EVERYONE_GROUP_NAME); assert($everyoneGroup->save()); // Not Coding Standard $group1 = new Group(); $group1->name = 'Group1'; assert($group1->save()); // Not Coding Standard }
public function makeAll(&$demoDataHelper) { assert('$demoDataHelper instanceof DemoDataHelper'); $group1 = new Group(); $group1->name = 'East'; $saved = $group1->save(); assert('$saved'); $group2 = new Group(); $group2->name = 'West'; $saved = $group2->save(); assert('$saved'); $group3 = new Group(); $group3->name = 'East Channel Sales'; $group3->group = $group1; $saved = $group3->save(); assert('$saved'); $group4 = new Group(); $group4->name = 'West Channel Sales'; $group4->group = $group2; $saved = $group4->save(); assert('$saved'); $group5 = new Group(); $group5->name = 'East Direct Sales'; $group5->group = $group1; $saved = $group5->save(); assert('$saved'); $group6 = new Group(); $group6->name = 'West Direct Sales'; $group6->group = $group2; $saved = $group6->save(); assert('$saved'); $demoDataHelper->setRangeByModelName('Group', $group1->id, $group6->id); }
public function testPoliciesUtilGetAllPoliciesData() { $group = new Group(); $group->name = 'viewGroup'; $saved = $group->save(); $this->assertTrue($saved); $this->assertEquals(null, $group->getEffectivePolicy('UsersModule', UsersModule::POLICY_ENFORCE_STRONG_PASSWORDS)); $group->setPolicy('UsersModule', UsersModule::POLICY_ENFORCE_STRONG_PASSWORDS, Policy::YES); $this->assertTrue($group->save()); $this->assertEquals(Policy::YES, $group->getEffectivePolicy('UsersModule', UsersModule::POLICY_ENFORCE_STRONG_PASSWORDS)); $this->assertEquals(Policy::YES, $group->getExplicitActualPolicy('UsersModule', UsersModule::POLICY_ENFORCE_STRONG_PASSWORDS)); $data = PoliciesUtil::getAllModulePoliciesDataByPermitable($group); $compareData = array('UsersModule' => array('POLICY_ENFORCE_STRONG_PASSWORDS' => array('displayName' => UsersModule::POLICY_ENFORCE_STRONG_PASSWORDS, 'explicit' => Policy::YES, 'inherited' => null, 'effective' => Policy::YES), 'POLICY_MINIMUM_PASSWORD_LENGTH' => array('displayName' => UsersModule::POLICY_MINIMUM_PASSWORD_LENGTH, 'explicit' => null, 'inherited' => null, 'effective' => 5), 'POLICY_MINIMUM_USERNAME_LENGTH' => array('displayName' => UsersModule::POLICY_MINIMUM_USERNAME_LENGTH, 'explicit' => null, 'inherited' => null, 'effective' => 3), 'POLICY_PASSWORD_EXPIRES' => array('displayName' => UsersModule::POLICY_PASSWORD_EXPIRES, 'explicit' => null, 'inherited' => null, 'effective' => null), 'POLICY_PASSWORD_EXPIRY_DAYS' => array('displayName' => UsersModule::POLICY_PASSWORD_EXPIRY_DAYS, 'explicit' => null, 'inherited' => null, 'effective' => null))); $this->assertEquals($compareData, $data); $group->forget(); }
public function addGroup() { $sectionCode = SectionCode::find(new MongoId(Input::get('section'))); if (isset($sectionCode->_id)) { $section = Subject::find($sectionCode->subject_id)->sections()->find($sectionCode->section_id); if (strcasecmp($section->current_code, $sectionCode->code) === 0) { $group = new Group(); $group->name = trim(ucfirst(Input::get('name'))); $group->teamleader_id = Auth::id(); $group->section_code_id = new MongoId($sectionCode->_id); $group->students_id = array(Auth::id()); $group->project_name = trim(strtolower(Input::get('project_name'))); $message = ""; if (Input::hasFile('avatar_file')) { $data = Input::get('avatar_data'); $image = new CropImage(null, $data, $_FILES['avatar_file']); $group->logo = $image->getURL(); } else { $group->logo = null; } try { $group->save(); } catch (MongoDuplicateKeyException $e) { return Redirect::back()->withErrors(array('error' => Lang::get('register_group.duplicated'))); } return Redirect::to(Lang::get('routes.add_group'))->with('message', Lang::get('register_group.success')); } else { $message = Lang::get('register_group.code_expired'); } } else { $message = Lang::get('register_group.code_fail'); } return Redirect::back()->withErrors(array('error' => $message)); }
public function __construct() { gateKeeper(); $title = getInput("title"); $description = getInput("description"); $access_id = getInput("access_id"); $membership = getInput("membership"); $group = new Group(); $group->title = $title; $group->description = $description; $group->access_id = $access_id; $group->membership = $membership; $group->owner_guid = getLoggedInUserGuid(); $group->save(); $group->createAvatar(); $test = getEntity(array("type" => "Groupmembership", "metadata_name_value_pairs" => array(array("name" => "group", "value" => $group->guid), array("name" => "member_guid", "value" => getLoggedInUserGuid())))); if (!$test) { $group_membership = new Groupmembership(); $group_membership->group = $group->guid; $group_membership->member_guid = getLoggedInUserGuid(); $group_membership->access_id = "system"; $group_membership->save(); } new Activity(getLoggedInUserGuid(), "group:created", array(getLoggedInUser()->getURL(), getLoggedInUser()->full_name, $group->getURL(), $group->title), $group->guid); new SystemMessage("Your group has been created."); forward("groups"); }
/** * Edits or Creates a user group */ public function actionEdit() { // Create Group Edit Form $group = Group::model()->findByPk(Yii::app()->request->getQuery('id')); if ($group === null) { $group = new Group(); } $group->scenario = 'edit'; $group->populateDefaultSpaceGuid(); $group->populateAdminGuids(); // uncomment the following code to enable ajax-based validation if (isset($_POST['ajax']) && $_POST['ajax'] === 'admin-group-form') { echo CActiveForm::validate($model); Yii::app()->end(); } if (isset($_POST['Group'])) { $_POST = Yii::app()->input->stripClean($_POST); $group->attributes = $_POST['Group']; if ($group->validate()) { $group->save(); // Redirect to admin groups overview $this->redirect(Yii::app()->createUrl('//admin/group')); } } $this->render('edit', array('group' => $group)); }
public function testMakeFormFromGroup() { $user = UserTestHelper::createBasicUser('Billy'); $billId = $user->id; unset($user); $user = User::getById($billId); $this->assertEquals('billy', $user->username); $user = UserTestHelper::createBasicUser('Jimmy'); $jimId = $user->id; unset($user); $user = User::getById($jimId); $this->assertEquals('jimmy', $user->username); $users = User::GetAll(); $allUsers = array(); foreach ($users as $user) { $allUsers[$user->id] = strval($user); } $this->assertEquals(3, count($allUsers)); $a = new Group(); $a->name = 'JJJ'; $this->assertTrue($a->save()); $this->assertEquals(0, $a->users->count()); $this->assertEquals(0, $a->groups->count()); $form = GroupUserMembershipFormUtil::makeFormFromGroup($a); $this->assertEquals(array(), $form->userMembershipData); $this->assertEquals($allUsers, $form->userNonMembershipData); }
/** * Show the form for creating a new resource. * * @return Response */ public function handleCreate() { $rules = array('name' => 'required|alpha'); $input = array('groupname' => Input::get('groupname')); $validator = Validator::make($input, array('groupname' => 'required')); if ($validator->fails()) { return Redirect::action('GroupController@index')->withErrors($validator)->withInput(Input::except('password')); } else { $permissions = Input::get('permissions'); $group = new Group(); $group->permissions = Input::get('permissions'); $groupname = Input::get('groupname'); $permns = $group->permissions; foreach ($permns as $key => $value) { if (strcmp($value, '0') == 0) { unset($permns[$key]); } } $arr2 = json_encode($permns, JSON_NUMERIC_CHECK); $group->name = $groupname; $group->permissions = $arr2; $group->save(); return Redirect::action('GroupController@index')->with('success', Lang::get('groups.create_success')); } }
public function postGroup($id = null) { if (Input::has('id')) { $group = Group::find(Input::get('id')); if (!$group->isGroupOwner(Auth::user()->id)) { return Response::json($this->growlMessage('You cannot modify a group you do not own.', 'error')); } $message = "Your group has been updated!"; } else { $group = new Group(); $group->status = Group::STATUS_PENDING; $message = "Your group has been created! It must be approved before you can invite others to join or create documents."; } $postData = array('name', 'display_name', 'address1', 'address2', 'city', 'state', 'postal_code', 'phone_number'); foreach ($postData as $field) { $group->{$field} = Input::get($field); } if ($group->validate()) { $group->save(); $group->addMember(Auth::user()->id, Group::ROLE_OWNER); if ($group->status === Group::STATUS_PENDING) { Event::fire(MadisonEvent::VERIFY_REQUEST_GROUP, $group); } return Response::json($this->growlMessage($message, 'success')); } else { return Response::json($this->growlMessage($group->getErrors()->all(), 'error'), 400); } }
/** * @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())); }
function update($vars, &$errors) { if (Group::save($this->getId(), $vars, $errors)) { $this->reload(); return true; } return false; }
public function prepareData() { # Create an existing group $group = new Group(); $group->name = 'Group One'; $group->save(); $this->previous_group = $group['id']; }
protected function setUp() { $grp = new Group(); $grp->destroy(); for ($i = 0; $i < 10; $i++) { $grp->create(array("title" => "title" . $i, "memo" => "memomemo")); $grp->save(); } }
public function create() { $this->load->library('form_validation'); $this->form_validation->set_rules('room[name]', 'lang:admin_rooms_form_field_name', 'required'); $this->form_validation->set_rules('room[time_begin]', 'lang:admin_rooms_form_field_time_begin', 'required|callback__is_time'); $this->form_validation->set_rules('room[time_end]', 'lang:admin_rooms_form_field_time_end', 'required|callback__is_time|callback__is_later_time'); $this->form_validation->set_rules('room[time_day]', 'lang:admin_rooms_form_field_time_day', 'required|callback__is_day'); $this->form_validation->set_rules('room[capacity]', 'lang:admin_rooms_form_field_capacity', 'required|integer|greater_than[0]'); $this->form_validation->set_rules('room[group_id]', 'group_id', 'required'); $this->form_validation->set_message('_is_time', $this->lang->line('admin_rooms_form_error_message_is_time')); $this->form_validation->set_message('_is_day', $this->lang->line('admin_rooms_form_error_message_is_day')); $this->form_validation->set_message('_is_later_time', $this->lang->line('admin_rooms_form_error_message_is_later_time')); if ($this->form_validation->run()) { $room_data = $this->input->post('room'); $this->_transaction_isolation(); $this->db->trans_begin(); $group = new Group(); $group->get_by_id($room_data['group_id']); if ($group->exists()) { $room = new Room(); $room->name = $room_data['name']; $room->time_day = intval($room_data['time_day']); $room->time_begin = $this->time_to_int($room_data['time_begin']); $room->time_end = $this->time_to_int($room_data['time_end']); $room->capacity = intval($room_data['capacity']); if (trim($room_data['teachers_plain']) != '') { $room->teachers_plain = trim($room_data['teachers_plain']); } else { $room->teachers_plain = NULL; } $teachers = new Teacher(); if (is_array($room_data['teachers']) && count($room_data['teachers'])) { foreach ($room_data['teachers'] as $teacher_id) { $teachers->or_where('id', $teacher_id); } $teachers->get(); } if ($room->save(array($teachers->all)) && $group->save($room) && $this->db->trans_status()) { $this->db->trans_commit(); $this->messages->add_message('lang:admin_rooms_flash_message_save_successful', Messages::MESSAGE_TYPE_SUCCESS); $this->_action_success(); $room->group->get(); $this->output->set_internal_value('course_id', $room->group->course_id); } else { $this->db->trans_rollback(); $this->messages->add_message('lang:admin_rooms_flash_message_save_failed', Messages::MESSAGE_TYPE_ERROR); } } else { $this->db->trans_rollback(); $this->messages->add_message('lang:admin_rooms_flash_message_group_not_found', Messages::MESSAGE_TYPE_ERROR); } redirect(create_internal_url('admin_rooms/new_room_form/' . intval($room_data['group_id']))); } else { $room_data = $this->input->post('room'); $this->new_room_form(intval($room_data['group_id'])); } }
public function saveAction() { $this->getRequest()->isPost(); $this->buildForm("admin/group/save"); if ($this->gForm->isValid($_POST)) { $values = $this->gForm->getValues(); } //Build Group Object $group = new Group(); //Upload Logo if (copy($values['logo'], Zend_Registry::get('config')->files->logo->dir . DIRECTORY_SEPARATOR . basename($values['logo']))) { $values['logo'] = Zend_Registry::get('config')->files->logo->dir . "/" . basename($values['logo']); } //Convert polygon cordenates preg_match_all("/\\(([0-9\\.\\,\\-\\s]*)\\)[\\,]?/", $values['area_coords'], $rawcoords); foreach ($rawcoords[1] as $coord) { $cvalues = explode(",", $coord); $cobj = new stdClass(); $cobj->lat = trim($cvalues[0]); $cobj->lng = trim($cvalues[1]); $coords[] = $cobj; } $values['area_coords'] = json_encode($coords); //Register Administrators $admins = explode(",", $values['admins']); foreach ($admins as $adm) { if ($adm != "") { $group->Admins[]->user_id = $adm; } } //Go through Activity Types $actvTypes = Doctrine_Query::create()->from('ActivityType')->orderBy("weight")->execute(); foreach ($actvTypes as $atype) { $atype_key = "atype_" . $atype->atype; $aSource = new ActivitySource(); $aSource->atype = $atype->atype; $aSource->target = $values[$atype_key]; $group->ActivitySources[] = $aSource; } //populate group $group->fromArray($values); //Save Group $group->save(); var_dump($values, $group->toArray()); //Grab pre-saved venues and tie group_id $venues = Doctrine_Query::create()->from('Venue')->where("Venue.name LIKE ?", array($values['tmp_id'] . '%'))->execute(); foreach ($venues as $venue) { $venue->name = str_replace($values['tmp_id'] . "_", "", $venue->name); $venue->group_id = $group->id; $venue->save(); } $this->_helper->flashMessenger("Group added!"); //$this->_helper->redirector('index'); $this->_helper->viewRenderer->setNoRender(); $this->_helper->layout->disableLayout(); }
public function createOrFindByName($sGroupName) { $oGroup = $this->filterByName($sGroupName)->findOne(); if ($oGroup === null) { $oGroup = new Group(); $oGroup->setName($sGroupName); $oGroup->save(); } return $oGroup; }
public function testSettingAndGetting() { Yii::app()->user->userModel = User::getByUsername('super'); $group1 = new Group(); $group1->name = 'Group1'; $this->assertTrue($group1->save()); $group2 = new Group(); $group2->name = 'Group2'; $this->assertTrue($group2->save()); $group3 = new Group(); $group3->name = 'Group3'; $this->assertTrue($group3->save()); $group4 = new Group(); $group4->name = 'Group4'; $this->assertTrue($group4->save()); $group5 = new Group(); $group5->name = 'Group5'; $this->assertTrue($group5->save()); $group6 = new Group(); $group6->name = 'Group6'; $this->assertTrue($group6->save()); $explicitReadWriteModelPermissions = new ExplicitReadWriteModelPermissions(); $this->assertEquals(0, $explicitReadWriteModelPermissions->getReadOnlyPermitablesCount()); $this->assertEquals(0, $explicitReadWriteModelPermissions->getReadWritePermitablesCount()); //Now add permitables and test retrieving them. $explicitReadWriteModelPermissions->addReadOnlyPermitable($group1); $explicitReadWriteModelPermissions->addReadWritePermitable($group2); $explicitReadWriteModelPermissions->addReadWritePermitable($group3); $explicitReadWriteModelPermissions->addReadOnlyPermitableToRemove($group4); $explicitReadWriteModelPermissions->addReadWritePermitableToRemove($group5); $this->assertEquals(1, $explicitReadWriteModelPermissions->getReadOnlyPermitablesCount()); $this->assertEquals(2, $explicitReadWriteModelPermissions->getReadWritePermitablesCount()); $this->assertEquals(1, $explicitReadWriteModelPermissions->getReadWritePermitablesToRemoveCount()); $this->assertEquals(1, $explicitReadWriteModelPermissions->getReadWritePermitablesToRemoveCount()); $readOnlyPermitables = $explicitReadWriteModelPermissions->getReadOnlyPermitables(); $readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables(); $this->assertEquals(1, count($readOnlyPermitables)); $this->assertEquals(2, count($readWritePermitables)); $this->assertEquals($group1, $readOnlyPermitables[$group1->id]); $this->assertEquals($group2, $readWritePermitables[$group2->id]); $this->assertEquals($group3, $readWritePermitables[$group3->id]); $readOnlyPermitablesToRemove = $explicitReadWriteModelPermissions->getReadOnlyPermitablesToRemove(); $readWritePermitablesToRemove = $explicitReadWriteModelPermissions->getReadWritePermitablesToRemove(); $this->assertEquals($group4, $readOnlyPermitablesToRemove[$group4->id]); $this->assertEquals($group5, $readWritePermitablesToRemove[$group5->id]); $this->assertTrue($explicitReadWriteModelPermissions->isReadOrReadWritePermitable($group1)); $this->assertTrue($explicitReadWriteModelPermissions->isReadOrReadWritePermitable($group2)); $this->assertTrue($explicitReadWriteModelPermissions->isReadOrReadWritePermitable($group3)); $this->assertFalse($explicitReadWriteModelPermissions->isReadOrReadWritePermitable($group4)); $this->assertFalse($explicitReadWriteModelPermissions->isReadOrReadWritePermitable($group5)); $this->assertFalse($explicitReadWriteModelPermissions->isReadOrReadWritePermitable($group6)); $this->assertEquals(1, count($explicitReadWriteModelPermissions->getReadWritePermitablesToRemove())); $explicitReadWriteModelPermissions->removeAllReadWritePermitables(); $this->assertEquals(3, count($explicitReadWriteModelPermissions->getReadWritePermitablesToRemove())); }
public function testModuleRightsUtilGetAllModuleRightsData() { $group = new Group(); $group->name = 'viewGroup'; $group->setRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_MOBILE); $saved = $group->save(); $this->assertTrue($saved); $data = RightsUtil::getAllModuleRightsDataByPermitable($group); $compareData = array('AccountsModule' => array('RIGHT_CREATE_ACCOUNTS' => array('displayName' => AccountsModule::RIGHT_CREATE_ACCOUNTS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_DELETE_ACCOUNTS' => array('displayName' => AccountsModule::RIGHT_DELETE_ACCOUNTS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_ACCESS_ACCOUNTS' => array('displayName' => AccountsModule::RIGHT_ACCESS_ACCOUNTS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY)), 'CampaignsModule' => array('RIGHT_CREATE_CAMPAIGNS' => array('displayName' => CampaignsModule::RIGHT_CREATE_CAMPAIGNS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_DELETE_CAMPAIGNS' => array('displayName' => CampaignsModule::RIGHT_DELETE_CAMPAIGNS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_ACCESS_CAMPAIGNS' => array('displayName' => CampaignsModule::RIGHT_ACCESS_CAMPAIGNS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY)), 'ContactsModule' => array('RIGHT_CREATE_CONTACTS' => array('displayName' => ContactsModule::RIGHT_CREATE_CONTACTS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_DELETE_CONTACTS' => array('displayName' => ContactsModule::RIGHT_DELETE_CONTACTS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_ACCESS_CONTACTS' => array('displayName' => ContactsModule::RIGHT_ACCESS_CONTACTS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY)), 'ContactWebFormsModule' => array('RIGHT_CREATE_CONTACT_WEB_FORMS' => array('displayName' => ContactWebFormsModule::RIGHT_CREATE_CONTACT_WEB_FORMS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_DELETE_CONTACT_WEB_FORMS' => array('displayName' => ContactWebFormsModule::RIGHT_DELETE_CONTACT_WEB_FORMS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_ACCESS_CONTACT_WEB_FORMS' => array('displayName' => ContactWebFormsModule::RIGHT_ACCESS_CONTACT_WEB_FORMS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY)), 'ConversationsModule' => array('RIGHT_CREATE_CONVERSATIONS' => array('displayName' => ConversationsModule::RIGHT_CREATE_CONVERSATIONS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_DELETE_CONVERSATIONS' => array('displayName' => ConversationsModule::RIGHT_DELETE_CONVERSATIONS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_ACCESS_CONVERSATIONS' => array('displayName' => ConversationsModule::RIGHT_ACCESS_CONVERSATIONS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY)), 'DesignerModule' => array('RIGHT_ACCESS_DESIGNER' => array('displayName' => DesignerModule::RIGHT_ACCESS_DESIGNER, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY)), 'EmailMessagesModule' => array('RIGHT_CREATE_EMAIL_MESSAGES' => array('displayName' => EmailMessagesModule::RIGHT_CREATE_EMAIL_MESSAGES, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_DELETE_EMAIL_MESSAGES' => array('displayName' => EmailMessagesModule::RIGHT_DELETE_EMAIL_MESSAGES, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_ACCESS_EMAIL_MESSAGES' => array('displayName' => EmailMessagesModule::RIGHT_ACCESS_EMAIL_MESSAGES, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_ACCESS_CONFIGURATION' => array('displayName' => EmailMessagesModule::RIGHT_ACCESS_CONFIGURATION, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY)), 'ExportModule' => array('RIGHT_ACCESS_EXPORT' => array('displayName' => ExportModule::RIGHT_ACCESS_EXPORT, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY)), 'HomeModule' => array('RIGHT_CREATE_DASHBOARDS' => array('displayName' => HomeModule::RIGHT_CREATE_DASHBOARDS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_DELETE_DASHBOARDS' => array('displayName' => HomeModule::RIGHT_DELETE_DASHBOARDS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_ACCESS_DASHBOARDS' => array('displayName' => HomeModule::RIGHT_ACCESS_DASHBOARDS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY)), 'JobsManagerModule' => array('RIGHT_ACCESS_JOBSMANAGER' => array('displayName' => JobsManagerModule::RIGHT_ACCESS_JOBSMANAGER, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY)), 'LeadsModule' => array('RIGHT_CREATE_LEADS' => array('displayName' => LeadsModule::RIGHT_CREATE_LEADS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_DELETE_LEADS' => array('displayName' => LeadsModule::RIGHT_DELETE_LEADS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_ACCESS_LEADS' => array('displayName' => LeadsModule::RIGHT_ACCESS_LEADS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_CONVERT_LEADS' => array('displayName' => LeadsModule::RIGHT_CONVERT_LEADS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY)), 'MapsModule' => array('RIGHT_ACCESS_MAPS_ADMINISTRATION' => array('displayName' => MapsModule::RIGHT_ACCESS_MAPS_ADMINISTRATION, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY)), 'NotesModule' => array('RIGHT_CREATE_NOTES' => array('displayName' => NotesModule::RIGHT_CREATE_NOTES, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_DELETE_NOTES' => array('displayName' => NotesModule::RIGHT_DELETE_NOTES, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_ACCESS_NOTES' => array('displayName' => NotesModule::RIGHT_ACCESS_NOTES, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY)), 'OpportunitiesModule' => array('RIGHT_CREATE_OPPORTUNITIES' => array('displayName' => OpportunitiesModule::RIGHT_CREATE_OPPORTUNITIES, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_DELETE_OPPORTUNITIES' => array('displayName' => OpportunitiesModule::RIGHT_DELETE_OPPORTUNITIES, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_ACCESS_OPPORTUNITIES' => array('displayName' => OpportunitiesModule::RIGHT_ACCESS_OPPORTUNITIES, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY)), 'GroupsModule' => array('RIGHT_CREATE_GROUPS' => array('displayName' => GroupsModule::RIGHT_CREATE_GROUPS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_DELETE_GROUPS' => array('displayName' => GroupsModule::RIGHT_DELETE_GROUPS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_ACCESS_GROUPS' => array('displayName' => GroupsModule::RIGHT_ACCESS_GROUPS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY)), 'ImportModule' => array('RIGHT_ACCESS_IMPORT' => array('displayName' => ImportModule::RIGHT_ACCESS_IMPORT, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY)), 'MeetingsModule' => array('RIGHT_CREATE_MEETINGS' => array('displayName' => MeetingsModule::RIGHT_CREATE_MEETINGS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_DELETE_MEETINGS' => array('displayName' => MeetingsModule::RIGHT_DELETE_MEETINGS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_ACCESS_MEETINGS' => array('displayName' => MeetingsModule::RIGHT_ACCESS_MEETINGS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY)), 'RolesModule' => array('RIGHT_CREATE_ROLES' => array('displayName' => RolesModule::RIGHT_CREATE_ROLES, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_DELETE_ROLES' => array('displayName' => RolesModule::RIGHT_DELETE_ROLES, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_ACCESS_ROLES' => array('displayName' => RolesModule::RIGHT_ACCESS_ROLES, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY)), 'TasksModule' => array('RIGHT_CREATE_TASKS' => array('displayName' => TasksModule::RIGHT_CREATE_TASKS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_DELETE_TASKS' => array('displayName' => TasksModule::RIGHT_DELETE_TASKS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_ACCESS_TASKS' => array('displayName' => TasksModule::RIGHT_ACCESS_TASKS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY)), 'ZurmoModule' => array('RIGHT_ACCESS_ADMINISTRATION' => array('displayName' => ZurmoModule::RIGHT_ACCESS_ADMINISTRATION, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_BULK_DELETE' => array('displayName' => ZurmoModule::RIGHT_BULK_DELETE, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_BULK_WRITE' => array('displayName' => ZurmoModule::RIGHT_BULK_WRITE, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_ACCESS_GLOBAL_CONFIGURATION' => array('displayName' => ZurmoModule::RIGHT_ACCESS_GLOBAL_CONFIGURATION, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_ACCESS_CURRENCY_CONFIGURATION' => array('displayName' => ZurmoModule::RIGHT_ACCESS_CURRENCY_CONFIGURATION, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY)), 'UsersModule' => array('RIGHT_CHANGE_USER_PASSWORDS' => array('displayName' => UsersModule::RIGHT_CHANGE_USER_PASSWORDS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_LOGIN_VIA_WEB' => array('displayName' => 'Sign in Via Web', 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_LOGIN_VIA_MOBILE' => array('displayName' => 'Sign in Via Mobile', 'explicit' => Right::ALLOW, 'inherited' => null, 'effective' => Right::ALLOW), 'RIGHT_LOGIN_VIA_WEB_API' => array('displayName' => 'Sign in Via Web API', 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_CREATE_USERS' => array('displayName' => UsersModule::RIGHT_CREATE_USERS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_ACCESS_USERS' => array('displayName' => UsersModule::RIGHT_ACCESS_USERS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY)), 'MissionsModule' => array('RIGHT_CREATE_MISSIONS' => array('displayName' => MissionsModule::RIGHT_CREATE_MISSIONS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_DELETE_MISSIONS' => array('displayName' => MissionsModule::RIGHT_DELETE_MISSIONS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_ACCESS_MISSIONS' => array('displayName' => MissionsModule::RIGHT_ACCESS_MISSIONS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY)), 'ReportsModule' => array('RIGHT_CREATE_REPORTS' => array('displayName' => ReportsModule::RIGHT_CREATE_REPORTS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_DELETE_REPORTS' => array('displayName' => ReportsModule::RIGHT_DELETE_REPORTS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_ACCESS_REPORTS' => array('displayName' => ReportsModule::RIGHT_ACCESS_REPORTS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY)), 'WorkflowsModule' => array('RIGHT_CREATE_WORKFLOWS' => array('displayName' => WorkflowsModule::RIGHT_CREATE_WORKFLOWS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_DELETE_WORKFLOWS' => array('displayName' => WorkflowsModule::RIGHT_DELETE_WORKFLOWS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_ACCESS_WORKFLOWS' => array('displayName' => WorkflowsModule::RIGHT_ACCESS_WORKFLOWS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY)), 'SocialItemsModule' => array('RIGHT_ACCESS_SOCIAL_ITEMS' => array('displayName' => 'Access Social Items', 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY)), 'MarketingModule' => array('RIGHT_ACCESS_MARKETING' => array('displayName' => MarketingModule::RIGHT_ACCESS_MARKETING, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY)), 'EmailTemplatesModule' => array('RIGHT_CREATE_EMAIL_TEMPLATES' => array('displayName' => EmailTemplatesModule::RIGHT_CREATE_EMAIL_TEMPLATES, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_DELETE_EMAIL_TEMPLATES' => array('displayName' => EmailTemplatesModule::RIGHT_DELETE_EMAIL_TEMPLATES, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_ACCESS_EMAIL_TEMPLATES' => array('displayName' => EmailTemplatesModule::RIGHT_ACCESS_EMAIL_TEMPLATES, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY)), 'MarketingListsModule' => array('RIGHT_CREATE_MARKETING_LISTS' => array('displayName' => MarketingListsModule::RIGHT_CREATE_MARKETING_LISTS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_DELETE_MARKETING_LISTS' => array('displayName' => MarketingListsModule::RIGHT_DELETE_MARKETING_LISTS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_ACCESS_MARKETING_LISTS' => array('displayName' => MarketingListsModule::RIGHT_ACCESS_MARKETING_LISTS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY)), 'ProductTemplatesModule' => array('RIGHT_CREATE_PRODUCT_TEMPLATES' => array('displayName' => ProductTemplatesModule::RIGHT_CREATE_PRODUCT_TEMPLATES, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_DELETE_PRODUCT_TEMPLATES' => array('displayName' => ProductTemplatesModule::RIGHT_DELETE_PRODUCT_TEMPLATES, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_ACCESS_PRODUCT_TEMPLATES' => array('displayName' => ProductTemplatesModule::RIGHT_ACCESS_PRODUCT_TEMPLATES, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY)), 'ProductsModule' => array('RIGHT_CREATE_PRODUCTS' => array('displayName' => ProductsModule::RIGHT_CREATE_PRODUCTS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_DELETE_PRODUCTS' => array('displayName' => ProductsModule::RIGHT_DELETE_PRODUCTS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_ACCESS_PRODUCTS' => array('displayName' => ProductsModule::RIGHT_ACCESS_PRODUCTS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY))); $this->assertEquals($compareData, $data); $group->forget(); }
/** * Создает новую модель Группы. * Если создание прошло успешно - перенаправляет на просмотр. * * @return void */ public function actionCreate() { $model = new Group(); if (Yii::app()->getRequest()->getPost('Group') !== null) { $model->setAttributes(Yii::app()->getRequest()->getPost('Group')); if ($model->save()) { Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('ListnerModule.listner', 'Запись добавлена!')); $this->redirect((array) Yii::app()->getRequest()->getPost('submit-type', ['update', 'id' => $model->id])); } } $this->render('create', ['model' => $model]); }
public function testModuleRightsUtilGetAllModuleRightsData() { $group = new Group(); $group->name = 'viewGroup'; $group->setRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_MOBILE); $saved = $group->save(); $this->assertTrue($saved); $data = RightsUtil::getAllModuleRightsDataByPermitable($group); $compareData = array('UsersModule' => array('RIGHT_CHANGE_USER_PASSWORDS' => array('displayName' => UsersModule::RIGHT_CHANGE_USER_PASSWORDS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_LOGIN_VIA_WEB' => array('displayName' => 'Sign in Via Web', 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_LOGIN_VIA_MOBILE' => array('displayName' => 'Sign in Via Mobile', 'explicit' => Right::ALLOW, 'inherited' => null, 'effective' => Right::ALLOW), 'RIGHT_LOGIN_VIA_WEB_API' => array('displayName' => 'Sign in Via Web API', 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_CREATE_USERS' => array('displayName' => UsersModule::RIGHT_CREATE_USERS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY), 'RIGHT_ACCESS_USERS' => array('displayName' => UsersModule::RIGHT_ACCESS_USERS, 'explicit' => null, 'inherited' => null, 'effective' => Right::DENY))); $this->assertEquals($compareData['UsersModule'], $data['UsersModule']); $group->forget(); }
/** * 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 = new Group(); $group->name = Input::get('name'); $group->description = Input::get('description'); $group->save(); return Redirect::route('groups.index'); }
public static function setUpBeforeClass() { parent::setUpBeforeClass(); SecurityTestHelper::createSuperAdmin(); $testGroup1 = new Group(); $testGroup1->name = 'testGroup1'; assert($testGroup1->save()); // Not Coding Standard $testGroup2 = new Group(); $testGroup2->name = 'testGroup2'; assert($testGroup2->save()); // Not Coding Standard }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Group(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Group'])) { $model->attributes = $_POST['Group']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }